I\'m trying to make a REST web service.
My project looks like :
<You are apparently required missing libraries from your deployment classpath.
Copy the following jars in the WEB-INF/lib directory
asm-3.1.jar
jackson-core-asl-1.9.2.jar
jackson-jaxrs-1.9.2.jar
jackson-mapper-asl-1.9.2.jar
jackson-xc-1.9.2.jar
jersey-client-1.15.jar
jersey-core-1.15.jar
jersey-json-1.15.jar
jersey-server-1.15.jar
jersey-servlet-1.15.jar
jettison-1.1.jar
jsr311-api-1.1.1.jar
The following dependency helps:
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.8</version>
</dependency>
See: http://www.mkyong.com/webservices/jax-rs/classnotfoundexception-com-sun-jersey-spi-container-servlet-servletcontainer/
You need to put the Jersey JAR in your WEB-INF/lib directory, whether you are running Tomcat separately or running with Eclipse.
This worked for me.
The class loader can't find the class com.sun.jersey.spi.container.servlet.ServletContainer
.
You need to put the Jersey JAR in your WEB-INF/lib
directory.
This might help:
http://www.suryasuravarapu.com/2009/02/rest-jersey-configuration-on-tomcat.html
Now I've looked at the image you posted and I see your problem: You're using Eclipse and Maven, but you don't really understand what they're doing.
You have to end up with a WAR file in the Tomcat /webapps
directory that has all the 3rd party JARs you need in the WEB-INF/lib
directory. If you don't, Tomcat won't find them.
I'd recommend simplifying your problem. Create a WAR file by hand; leave Eclipse and Maven out of it. Once you've got it working, add in the things that are supposed to be making your life easier. You'll understand what they need to do, because you'll have already made it work without them.
In Jersey 2.0, the servlet container implementation changed. You need to use org.glassfish.jersey.servlet.ServletContainer instead of the old com.sun.jersey.spi.container.servlet.ServletContainer
The class is in
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<version>2.0-m11</version>
</dependency>
You can create a skeletal project using:
mvn archetype:generate -DarchetypeArtifactId=jersey-quickstart-webapp -DarchetypeGroupId=org.glassfish.jersey.archetypes -
DinteractiveMode=false -DgroupId=com.example -DartifactId=simple-service -Dpackage=com.example -DarchetypeVersion=2.0-m11
from: http://jersey.java.net/nonav/documentation/latest/chapter_deps.html#d4e1687
Deploying an application on a servlet container requires a deployment dependency with that container.
See the Java documentation here on how to configure the servlet container.
Using servlet: com.sun.jersey.spi.container.servlet.ServletContainer requires a dependency on the jersey-servlet module.
Maven developers using servlet: com.sun.jersey.server.impl.container.servlet.ServletAdaptor in a non-EE 5 servlet require a dependency on the persistence-api module in addition.
Non-Maven developers require: persistence-api.jar