jQuery in Action, 2nd edition*
The moose likes JBoss/WildFly and the fly likes java.lang.LinkageError: loader constraint violation: when resolving method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "java.lang.LinkageError: loader constraint violation: when resolving method "org.slf4j.impl.StaticLog" Watch "java.lang.LinkageError: loader constraint violation: when resolving method "org.slf4j.impl.StaticLog" New topic
Author

java.lang.LinkageError: loader constraint violation: when resolving method "org.slf4j.impl.StaticLog

meenakshi gavhale
Greenhorn

Joined: Apr 13, 2012
Posts: 8
hi,


while starting the JBoss Server
i get the following error
java.lang.LinkageError: loader constraint violation: when resolving method "org.slf4j.impl.StaticLoggerBinder.getLoggerFactory()Lorg/slf4j/ILoggerFactory;" the class loader (instance of org/jboss/classloader/spi/base/BaseClassLoader) of the current class, org/slf4j/LoggerFactory, and the class loader (instance of org/jboss/classloader/spi/base/BaseClassLoader) for resolved class, org/slf4j/impl/StaticLoggerBinder, have different Class objects for the type org/slf4j/ILoggerFactory used in the signature

how to resolve it?

thanks in advanced.
William P O'Sullivan
Ranch Hand

Joined: Mar 28, 2012
Posts: 859

JBoss has already loaded the Class from a different jar.

I just fought through many of these replace xfire with cxf.

I way I fixed it was to turn verbose on using the jvm -verbose parameter.
Save the output to a text file and find out where the first instance is loaded.
The next one that breaks will tell you which jar to remove.

WP
William P O'Sullivan
Ranch Hand

Joined: Mar 28, 2012
Posts: 859

In one case:

Caused by: java.lang.ClassNotFoundException: Unexpected error during load of: javax.xml.namespace.QName, msg=loader constraint violation: loader (instance of org/jboss/mx/loading/UnifiedClassLoader3) previously initiated loading for a different type with name "javax/xml/namespace/QName"
at org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:553)
at org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:408)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 163 more
Caused by: java.lang.LinkageError: loader constraint violation: loader (instance of org/jboss/mx/loading/UnifiedClassLoader3) previously initiated loading for a different type with name "javax/xml/namespace/QName"

So looking at the verbose output, I found:

[Loaded javax.xml.namespace.QName from C:\Program Files\Java\jdk1.6.0_23\jre\lib\rt.jar]

then ...

[Loaded javax.xml.namespace.QName from file:/C:/jboss-eap-4.3/jboss-as-483/server/xxxxxSNAPSHOT.war/WEB-INF/lib/stax-api-1.0.1.jar]
[Loaded java.lang.ClassCircularityError from C:\Program Files\Java\jdk1.6.0_23\jre\lib\rt.jar]
[Loaded javax.xml.namespace.QName from file:/C:/jboss-eap-4.3/jboss-as-483/server/xxxxxSNAPSHOT.war/WEB-INF/lib/stax-api-1.0.1.jar]

So, removing stax-api-1.0.1.jar from our webapp fixed this problem!!

WP
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.lang.LinkageError: loader constraint violation: when resolving method "org.slf4j.impl.StaticLog