Drools runtime error - java

I'm trying to run Drools sample ( the HelloWorld sample when creating a new Drools project ), I didn't change anything in the project but I'm getting an error.
Here's the stacktrace:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
org.drools.RuntimeDroolsException: Unable to load dialect 'org.drools.rule.builder.dialect.java.JavaDialectConfiguration:java:org.drools.rule.builder.dialect.java.JavaDialectConfiguration'
at org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuilderConfiguration.java:321)
at org.drools.compiler.PackageBuilderConfiguration.buildDialectConfigurationMap(PackageBuilderConfiguration.java:307)
at org.drools.compiler.PackageBuilderConfiguration.init(PackageBuilderConfiguration.java:192)
at org.drools.compiler.PackageBuilderConfiguration.<init>(PackageBuilderConfiguration.java:170)
at org.drools.compiler.PackageBuilder.<init>(PackageBuilder.java:300)
at org.drools.compiler.PackageBuilder.<init>(PackageBuilder.java:228)
at org.drools.builder.impl.KnowledgeBuilderFactoryServiceImpl.newKnowledgeBuilder(KnowledgeBuilderFactoryServiceImpl.java:34)
at org.drools.builder.KnowledgeBuilderFactory.newKnowledgeBuilder(KnowledgeBuilderFactory.java:46)
at com.sample.DroolsTest.readKnowledgeBase(DroolsTest.java:39)
at com.sample.DroolsTest.main(DroolsTest.java:23)
Caused by: java.lang.RuntimeException: The Eclipse JDT Core jar is not in the classpath
at org.drools.rule.builder.dialect.java.JavaDialectConfiguration.setCompiler(JavaDialectConfiguration.java:100)
at org.drools.rule.builder.dialect.java.JavaDialectConfiguration.init(JavaDialectConfiguration.java:61)
at org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuilderConfiguration.java:317)
... 9 more
I'm running the project in eclipse IDE

Like Sid said, the jar is in your eclipse plugin directory. For my windows box, this is C:\Program Files\eclipse\plugins\org.eclipse.jdt.core_3.8.2.v20120814-155456.jar

You may need to add the library org.eclipse.core.jdt-version that is on your
eclipse plugins folder to your classpath.

Adding onto what Sid and Furrald already mentioned.
Stating just an obvious, but if someone is wondering where they can find the jar for JBoss Dev Studio on a Linux: I have it at
<path-to-devStudio>/devstudio/studio/plugins/<name-and-version-of-jdt-core>.jar

Related

Apache James 3.7.2 Spring - SLF4J: No SLF4J providers were found

I downloaded a binary distribution of Apache James, the Spring wired distribution.
I run it but I get the below error:
C:\prod\james-server-spring-app-3.7.2\bin>run
SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See https://www.slf4j.org/codes.html#noProviders for further details.
SLF4J: Class path contains SLF4J bindings targeting slf4j-api versions 1.7.x or earlier.
SLF4J: Ignoring binding found at [jar:file:/C:/prod/james-server-spring-app-3.7.2/lib/log4j-slf4j-impl-2.17.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See https://www.slf4j.org/codes.html#ignoredBindings for an explanation.
https://james.apache.org/server/monitor-logging.html
The distribution is unchanged but in "\conf" folder there is not the "log4j.properties" as stated in the official documentation.
Instead there is the "log4j2.xml" file.
In "\lib" folder there are the below libs:
slf4j-api-2.0.1.jar
log4j-api-2.17.1.jar
log4j-core-2.17.1.jar
log4j-slf4j-impl-2.17.1.jar
Please could someone help me to start James in mode that I can follow the activities?
Thank you in advance.
Ivano
SOLVED
The important message is the below:
SLF4J: Class path contains SLF4J bindings targeting slf4j-api versions 1.7.x or earlier.
So I replaced the libs distribued from Apache James community with the below libs:
log4j-api-2.19.0.jar
log4j-core-2.19.0.jar
log4j-slf4j2-impl-2.19.0.jar
slf4j-api-2.0.5.jar
The above combination of libs makes slf4j happy to works with log4j log provider.

Package dependencies in a jar

I'm trying with a .jar library but the init method has a call to slf4j. I have added slf4j to my dependencies Project but I believe that I need to repackage the library with the dependency inside the jar.
The method I'm calling in the jar has this line:
private static final org.slf4j.Logger LOG =
org.slf4j.LoggerFactory.getLogger(Init.class);
But I have this error:
SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#noProviders for further details.
You also need an slf4j implementation, just as your error said. There are multiple. Here are a two:
slf4j-simple: it prints out to your console/terminal
log4j-slf4j-impl: The Apache Log4j SLF4J API binding to Log4j 2 Core
If you need just the .jar, choose your needed version and you can download it under files.
If you need more help, the official manual explains it quite good.
Hope I could help you

Java sl4j-log4j logging libraries not working properly

.
I'm trying to compile a java program using these jars(screenshot) but getting these errors:
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/vanar/workspace/TwitterKafka/logback-classic-1.1.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/vanar/workspace/TwitterKafka/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
Exception in thread "hosebird-client-io-thread-0" java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;Ljava/lang/Throwable;)V
at org.apache.commons.logging.impl.SLF4JLocationAwareLog.debug(SLF4JLocationAwareLog.java:120)
at org.apache.http.impl.conn.PoolingClientConnectionManager.shutdown(PoolingClientConnectionManager.java:276)
at com.twitter.hbc.httpclient.ClientBase.run(ClientBase.java:165)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
how do I ensure all these logging components work together?
I am stumped as to what is compatible with what and do not know a way apart from trial and error which I tried with no luck. please help
You can try to add logging jar files to endorsed directory.
Use latest combination of slf4j-log4j .You are using older version of any one of this jars.
add log4j and sl4j jar in this combination. if any one is missing exception raised while logging.

Using solrj library

I'm trying to use solrj library in order to do some indexing work on my Cloudera Sorl server.
At this point
String zkHostString = "http://xxx.xxx.xxx.xxx:xxxx/solr";
CloudSolrClient solr = new CloudSolrClient(zkHostString);
I got error
> SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
> SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J:
> See http://www.slf4j.org/codes.html#StaticLoggerBinder for further
File slf4j-api-1.7.7.jar exists in my library path (I got all jar files from /dist and /dist/solrj-lib)
To build my project I'm using Eclipse if it doues matter.
Most likely you have old version of slf4j in your classpath, that came from a transitive dependency. Try to check this and then run dependency tree or any other tool to find and resolve the conflicts.

failed to load class 'org.slf4j.impl.StaticLoggerBinder'

I created a jar file with all the dependencies, and I implemented the logging using slf4j + logback. Thus I have a logback.xml file defined for all the loggers. However when I run the jar it gave me this message:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
I dont see any logging happening. After I unzip the jar file, I can see the org.slf4j folder. I don't know why this is not working.
From http://www.slf4j.org/codes.html#StaticLoggerBinder (the link in the message):
This error is reported when the org.slf4j.impl.StaticLoggerBinder
class could not be loaded into memory. This happens when no
appropriate SLF4J binding could be found on the class path. Placing
one (and only one) of slf4j-nop.jar, slf4j-simple.jar,
slf4j-log4j12.jar, slf4j-jdk14.jar or logback-classic.jar on the class
path should solve the problem. SINCE 1.6.0 As of SLF4J version 1.6, in
the absence of a binding, SLF4J will default to a no-operation (NOP)
logger implementation. You can download SLF4J bindings from the
project download page.
In other words, you need a slf4j backend in your classpath, e.g. logback.
It seems logback-classic.jar is missing from classpath.
Take a look at http://slf4j.org/manual.html#swapping.
Is this a scala project? If yes then adding the below dependency will help. It worked for me.
"org.slf4j" % "slf4j-simple" % "1.7.12"

Categories

Resources