java.lang.ClassNotFoundException: org.glassfish.jersey.servlet.ServletContainer

后端 未结 10 1472
名媛妹妹
名媛妹妹 2020-12-14 20:58

You may feel this is a duplicated question, but none of the questions with the same title solve my problems. I am using Jersey 2.0 creating a RESTful web service in Eclipse,

10条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-14 21:47

    I got this problem with Eclipse. My project which has a very similar setup - Jersey 2, Tomcat 7. I'm running tomcat from inside eclipse, and it seems that somewhere along the way eclipse sort of forgot how to deploy the libraries to tomcat properly.

    I tried deploying my war file manually to tomcat and starting it via startup.sh and it worked fine, but if I start it up via eclipse I get my web content but the Jersey classes aren't there so the REST API doesn't work. My login servlet works fine, just not the jersey bit. The console has the same error:

    java.lang.ClassNotFoundException: org.glassfish.jersey.servlet.ServletContainer
    

    on startup. So it must be a problem with how eclipse deploys code to tomcat. I tried going into eclipse servers and clearing the work dir, didn't do anything. (not that it would, for missing classes).

    The only thing that worked was going to my Servers config in Eclipse and deleting my tomcat entry then creating a new one. I did that and it fixed it straight away.

提交回复
热议问题