slf4j exception with quartz - exception

I am trying to use quartz in a simple example in project. I am getting the following exception, I am not sure what it means...However I updated my slf4j to 1.6.1 in my POM file even then this still appears,
SLF4J: slf4j-api 1.6.x (or later) is incompatible with this binding.
SLF4J: Your binding is version 1.5.5 or earlier.
SLF4J: Upgrade your binding to version 1.6.x. or 2.0.x
Exception in thread "main" java.lang.NoSuchMethodError: org.slf4j.impl.StaticLoggerBinder.getSingleton()Lorg/slf4j/impl/StaticLoggerBinder;
at org.slf4j.LoggerFactory.bind(LoggerFactory.java:121)
at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:111)
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:268)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:241)
at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:155)
at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:131)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:395)
at org.quartz.impl.StdSchedulerFactory.<init>(StdSchedulerFactory.java:249)
............
Any help on this would be highly appreciated. Thanks.

You need all your SLF4J dependencies to use the same version.
SLF4J: Your binding is version 1.5.5 or earlier.
SLF4J: Upgrade your binding to version 1.6.x. or 2.0.x
If you look at your dependency tree, I expect that you'll find more then one version of SLF4J for the various jar it uses.
For example
[INFO] +- org.hibernate:hibernate-core:jar:3.5.3-Final:compile
[INFO] | +- antlr:antlr:jar:2.7.7:compile (version managed from 2.7.6)
[INFO] | \- org.slf4j:slf4j-api:jar:1.5.8:compile
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.5.8:compile
Here the two slf4j deps have the same version.

Looks like the SLF4J binding used inside quartz is too old. You should exclude the old version from quartz and add a new one explicitly to your project. Run mvn dependency:tree and post your result here. I will be able to give you exact instructions then.

Related

maven goal issue with active jdbc

While adding instrumentation plugin in pom.xml am getting this error
Plugin execution not covered by lifecycle configuration:org.javalite:activejdbc-instrumentation:1.4.13:instrument (execution: default, phase: process-classes
If added all plugin inside pluginManagement then no error but this package org.javalite.activejdbc.Model not importing can you please assist me.
It is indeed a duplicate of How to solve "Plugin execution not covered by lifecycle configuration" for Spring Data Maven Builds.
However, JavaLite documentation provides a more concrete set of instructions for Eclipse configuration.

Handlebars-proto and logstash-logback-encoder slf4j conflict

My project uses handlebars-proto to bind templates to json. Also i am trying to use logstash-logback-encoder to log in form of Json for logstash. Below are my compile dependencies ( along with other dependencies)
compile 'net.logstash.logback:logstash-logback-encoder:4.6'
compile 'com.github.jknack:handlebars-proto:4.0.5'
If I remove handlebars dependency logging works fine. If handlebars is present I get the below warning :
SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found
binding in
[jar:file:/C:/Users/manish/.gradle/caches/modules-2/files-2.1/com.github.jknack/handlebars-proto/4.0.5/5979737344d99e0d8b482e828f247ae86fd0113/handlebars-proto-4.0.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in
[jar:file:/C:/Users/manish/.gradle/caches/modules-2/files-2.1/ch.qos.logback/logback-classic/1.1.6/665e3de72f19ec66ac67d82612d7b8e6b3de3cd0/logback-classic-1.1.6.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an
explanation.
followed by error :
Failed to instantiate [ch.qos.logback.classic.LoggerContext] Reported
exception:
java.lang.NoSuchMethodError: ch.qos.logback.core.spi.ContextAwareBase.(Lch/qos/logback/core/spi/ContextAware;)V
at
net.logstash.logback.composite.CompositeJsonFormatter.(CompositeJsonFormatter.java:106)
at
net.logstash.logback.composite.loggingevent.LoggingEventCompositeJsonFormatter.(LoggingEventCompositeJsonFormatter.java:28)
at
net.logstash.logback.LogstashFormatter.(LogstashFormatter.java:122)
at
net.logstash.logback.LogstashFormatter.(LogstashFormatter.java:118)
at
net.logstash.logback.LogstashFormatter.(LogstashFormatter.java:114)
at
net.logstash.logback.encoder.LogstashEncoder.createFormatter(LogstashEncoder.java:31)
at
net.logstash.logback.encoder.CompositeJsonEncoder.(CompositeJsonEncoder.java:48)
at
net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder.(LoggingEventCompositeJsonEncoder.java:23)
at
net.logstash.logback.encoder.LogstashEncoder.(LogstashEncoder.java:27)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method) at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at java.lang.Class.newInstance(Class.java:379) at
ch.qos.logback.core.joran.action.NestedComplexPropertyIA.begin(NestedComplexPropertyIA.java:122)
at
ch.qos.logback.core.joran.spi.Interpreter.callBeginAction(Interpreter.java:276)
at
ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:148)
at
ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:130)
at
ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:50)
I tried excluding slf4j as transitive dependency from handlebars but
it did not help.
compile
('com.github.jknack:handlebars-proto:4.0.5'){
exclude module: 'slf4j-api'
}
Thanks in advance for help. Let me know if more details are required.
The error message is because the handlebars-proto jar contains an implementation of org.slf4j.impl.StaticLoggerBinder, which means that it has a logging implementation. You are also trying to add your own logging implementation of Logback, and since SLF4J can't use two logging systems at once, it's complaining.
I'm not familiar with the handlebars project, but I'm guessing that the library you have there is a full application that includes a logging system, and not really designed to be used as a dependency by another project. Perhaps there's a different version available that is just the library, and that doesn't try to include its own logging implementation?

Missing Java3D on tomcat cartridge

I have small gear with tomcat cartridge. When I try to execute war that that generate images with Java3D I get following exception:
Caused by: java.lang.ClassNotFoundException: javax.media.j3d.Node
As a first think I tried to add Java3D at classpath, I have added to my pom.xml:
<dependency>
<groupId>java3d</groupId>
<artifactId>j3d-core-utils</artifactId>
<version>1.3.1</version>
<scope>compile</scope>
</dependency>
This added to final war following artifacts:
[INFO] +- java3d:j3d-core-utils:jar:1.3.1:compile
[INFO] | +- java3d:vecmath:jar:1.3.1:compile
[INFO] | \- java3d:j3d-core:jar:1.3.1:compile
When I deployd adjusted war following exception raised:
Caused by: java.lang.UnsatisfiedLinkError: no J3D in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1886)
As far as I understand exception, it says that there are no native Java3D libraries at java.library.path. So I installed Java3D from suggested link, I also updated j3dcore.jar, j3dutils.jar and vecmath.jar. Also catalina.sh was updated:
export LD_LIBRARY_PATH=/var/lib/openshift/<my-application-id>/app-root/data/j3d-1_5_2-linux-amd64/lib/amd64
I suppose that there is no X11 server to work with, because of that Java3D have to run in headless mode. It could be set in catalina.sh like this:
JAVA_OPTS=${JAVA_OPTS}" -Djava.awt.headless=true"
Now it seems that all java3D classes and *.so libraries are found. Now there is another problem:
java.awt.HeadlessException
at sun.java2d.HeadlessGraphicsEnvironment.getDefaultScreenDevice(HeadlessGraphicsEnvironment.java:64)
Problem is that Java3D class Canvas3D can't work in headless mode. Only way could be to connect to some X11 server with screen. It could be done with export DISPLAY=:0.0
As far as I was able to test, it seems that there is no X11 server, providing screen to which could Java3D connect. Because of that it's not possible to run Java3D at OpenShift platform with tomcat cartridge.
Thanks for your help.
Have you tried adding it to your pom.xml to get installed via maven? Or add the .jar file to your project manually... http://mvnrepository.com/artifact/java3d/j3d-core-utils/1.3.1
You might require more than just the core package.
Since you are deploying a war file, and not using maven, i think you would need to download the jar files and embed them in your war file as libraries and use them.
You might also check out this article: https://www.openshift.com/kb/kb-e1087-how-to-include-libraries-jar-files-in-your-java-application-without-using-maven
It looks like there is also a .so file that you would need to include with something like -Djava.library.path
Here is the file with the jars & .so file on java.net http://download.java.net/media/java3d/builds/release/1.5.2/j3d-1_5_2-linux-amd64.zip
Speaking with the dev ops team, it does not seem that package is installed on the servers.

Grails IncompatibleClassChangeError

I deploy a war made with "grails war" to a jetty server.
As far as I can determine, Grails builds with Sun JDK 1.6.0_17-b04 and jetty runs on Sun JDK 1.6.0.16 (both on linux).
2010-08-18 07:33:47.018:WARN::Nested in org.springframework.beans.factory.access.BootstrapException: Error executing bootstraps; nested exception is org.codehaus.groovy.runtime.InvokerInvocationException:
java.lang.IncompatibleClassChangeError: the number of constructors during runtime and compile time for java.lang.ClassLoader do not match. Expected 3 but got 2:
java.lang.IncompatibleClassChangeError: the number of constructors during runtime and compile time for java.lang.ClassLoader do not match. Expected 3 but got 2
at grails.plugin.scopedproxy.AlwaysReloadableSmartClassLoader.<init>(AlwaysReloadableSmartClassLoader.groovy:28)
at grails.plugin.scopedproxy.ScopedProxyUtils.wrapInSmartClassLoader(ScopedProxyUtils.groovy:154)
How can this problem be solved or debugged further?
Run grails clean before you run grails war.
According to another post, Groovy code that uses exceptions that was compiled with a version of Java prior to 7 is not compatible with Java 7.
More information can be found here.
You are probably running into a JAR conflict. Namely your build environment is using one jar, and runtime (Jetty) is using a conflicting jar. This used to often happen with various XML parsing stacks.
Try looking at the Jars used by jetty and compare them to the ones in your project.

Quartz Scheduler - NoClassDefFoundError

I am using Quratz 1.6.3 API in a Maven project. This is the error message I get when I run it:
java.lang.NoClassDefFoundError: org/apache/commons/collections/SetUtils
at org.quartz.JobDetail.(JobDetail.java:85)
.....
commons.collections 3.2 dependency is included in the project's pom.xml file. What could be the reason for this error?
Thanks in advance.
commons.collections 3.2.1 contains this class
org\apache\commons\collections\SetUtils.class
So the problem should be in your maven project. Double check that the commons.collections gets is the classpath (see logs). Or show the project configuration, so we would be able to help.