Reputation: 37
I am getting this exception:
java.lang.NoSuchMethodError: org.jboss.logging.Logger.getMessageLogger(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Object;
at org.hibernate.ejb.Ejb3Configuration.<clinit>(Ejb3Configuration.java:142)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:55)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63)
Why? There are two jars containing the class Logger. The jars are:
-jboss-logging-spi and jboss-logging
Jboss-logging-spi.jar is a transitive dependency of the jbosscache-core.jar and unfortunately it gets loaded first by Tomcat 8.
What is the best way to fix this? Is it possible to control the order in which the .jars are loaded by Tomcat?
Additional information:
-The current .war file which I can't get it working on the new server(Ubuntu) it is working on the old server(OpenSuse).
Upvotes: 2
Views: 535
Reputation: 20882
Explicit JAR-ordering can be accomplished in Tomcat via abusing the resources
facility in Tomcat. I'm not going to give a complete answer, here, because (a) it's highly non-recommended and (b) you'd better really know what you are doing in order to do it.
So, briefly:
<PreResources>
to force a library or libraries to the front of the lineUpvotes: 0
Reputation: 48087
What is the best way to fix this?
Eliminate the duplicate classes. Period. There's no other recommendation. Masking the problem through class loading order will have a similar problem pop up later, making maintenance harder next time.
One application should never contain two conflicting implementations (or even two identical implementations) of the same class. If one of the classes is on the (appserver-) global classpath: Remove it from there.
Upvotes: 2