简体   繁体   中英

Unable to deploy Restful simple code on Tomcat 7. error java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer

I have downloaded and imported jars of jersey 1.16 , jersey 1.17 and jersey2.23 version separately and together( jersey 2.23 and jersey 1.16 ). The code gets compiled properly but getting the above error when I try to deploy on Tomcat 7 .

I have referred the following tutorials:

  1. RESTful Java client with Jersey client

  2. Implementing RESTFul service with Java

If I use only jersey 2.23 jar then it's throwing error. When I import and use Client package hence I added Jersey-Client-1.2.jar to avoid those error and I also added jersey-container-servlet-core jar to Tomcat lib folder. But error is still existing. Error :

java.lang.ClassNotFoundException: 
com.sun.jersey.spi.container.servlet.ServletContainer

To solve this issue, correct the project dependencies in pom.xml like below. If you are not using maven for project dependencies, include the corresponding jar files in classpath.

<dependency>
    <groupId>com.sun.jersey</groupId>
    <artifactId>jersey-server</artifactId>
    <version>1.17.1</version>
</dependency>
<dependency>
    <groupId>com.sun.jersey</groupId>
    <artifactId>jersey-core</artifactId>
    <version>1.17.1</version>
</dependency>
<dependency>
    <groupId>com.sun.jersey</groupId>
    <artifactId>jersey-servlet</artifactId>
    <version>1.17.1</version>
</dependency>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM