I was working on writing some servlets and they all worked fine Tomcat had no issue running what so ever. Then I wrote a class file that used JERSEY and when I tried to run
I got the same issue today. Eventually it turned out to be that a user library became empty. However the error message shown did not give any hints about that.
javax/servlet/ServletContainerInitializer
is a class in Servlet 3.0
which is not support in Tomcat 6.
You probably have servlet.jar
floating around somewhere in your CLASSPATH, it shouldn't be. This really messes up the classloaders since Tomcat's classloaders don't act quite as normal as one expects (see links above). servlet.jar
should only be found only once in $CATALINA_HOME/lib
.
Sometimes if you are running a Tomcat server in Eclipse, the local Tomcat working directory can get jacked up and you have to clear it explicitly. Note that this is NOT the same as doing a Clean build on the project: From the Servers window: Right click on the server you are trying to start->Clean Tomcat work Directory...->OK
A late answer but this may help someone.
I believe this happens because the Jersey was created using a newer java version and you're trying to run it in an older version of java. Either update your java version or download an older version of Jersey that supports your java version.
Window -> Preferences -> Java -> Compiler -> set "Compiler compliance level" to 1.7.
From Jersey documentation:
Until version 2.6, Jersey was compiled with Java SE 6. This has changes in Jersey 2.7.
Now almost all Jersey components are compiled with Java SE 7 target. It means, that
you will need at least Java SE 7 to be able to compile and run your application
that is using latest Jersey. Only core-common and core-client modules are still
compiled with Java class version runnable with Java SE 6.
simple right click on tomcat server then clean the tomcat work directory then clean the tomcat. it will work.