java.lang.ClassNotFoundException: javax.servlet.ServletContainerInitializer

后端 未结 5 819
被撕碎了的回忆
被撕碎了的回忆 2020-12-19 02:16

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

相关标签:
5条回答
  • 2020-12-19 02:27

    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.

    0 讨论(0)
  • 2020-12-19 02:28

    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.

    0 讨论(0)
  • 2020-12-19 02:30

    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

    0 讨论(0)
  • 2020-12-19 02:30

    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. 
    
    0 讨论(0)
  • 2020-12-19 02:51

    simple right click on tomcat server then clean the tomcat work directory then clean the tomcat. it will work.

    0 讨论(0)
提交回复
热议问题