Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tomcat deployment problem using jar file instead of classes

Tags:

java

jar

tomcat

war

We're deploying a WAR file into Tomcat 5.5 and it works fine if WEB-INF\classes contains .classes files, but if we move the .jar file containing that .classes into WEB-INF\lib, we get an exception on runtime complaining that java.lang.NoSuchMethodError, but existing class file in .jar file contains the class and method does exits!

Any help on this would be appreciated.

like image 625
Hadi Eskandari Avatar asked Oct 26 '25 10:10

Hadi Eskandari


2 Answers

This could be caused due to a class conflict. Make sure that there isn't an older version of the Class somewhere (Tomcat's shared folder, WEB-INF/classes, WEB-INF/lib). If this is the case, you practically can't know which class Tomcat will load. If it picks one without the method, the exception you are experiencing will occur.

like image 102
kgiannakakis Avatar answered Oct 28 '25 23:10

kgiannakakis


Since you are getting a NoSuchMethodError, and not a ClassNotFoundError, it means that you have an old version of the class somewhere (outside of the jar file). You need to find and remove it.

like image 36
Thilo Avatar answered Oct 29 '25 00:10

Thilo