12
votes

I am trying to get a RESTful web service (JAX-RS) going with Tomcat7. I have tried 3 different implementations (Jersey, RESTeasy and Restlet) with no success. This should be easy but somehow it is not. I am looking for an up to date tutorial/documentation for annotations, web.xml and sample code.

5
Check the Jersey document, 4.7.1. Servlet 2.x Container.Hong

5 Answers

1
votes

I know it has been a while since you posted this question. Most likely you figured it out by now but I would like to answer in case anyone else might benefit.

Here are some tutorials that could get you started:

http://www.javacodegeeks.com/2011/01/restful-web-services-with-resteasy-jax.html

http://www.vogella.de/articles/REST/article.html

http://www.mastertheboss.com/web-interfaces/273-resteasy-tutorial-.html

1
votes

If you want to create a Servlet container deployable Jersey web application use

mvn archetype:generate -DarchetypeGroupId=org.glassfish.jersey.archetypes \
    -DarchetypeArtifactId=jersey-quickstart-webapp -DarchetypeVersion=2.26
0
votes

I'm using both Apache Wink and Jersey with Tomcat 7 and have no problems.

In web.xml I have:

<servlet>
    <servlet-name>restSdkService</servlet-name>
    <!-- When running with Jersey use the following class: com.sun.jersey.spi.container.servlet.ServletContainer -->
    <!-- When running with Wink use the following class: org.apache.wink.server.internal.servlet.RestServlet -->
    <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
    <init-param>
        <param-name>javax.ws.rs.Application</param-name>
        <param-value>mypackage.MyApplication</param-value>
    </init-param>
</servlet>

May be you should elaborate what problems/exceptions you get.

0
votes

tomcat 7.0.29

<dependency>
  <groupId>org.apache.cxf</groupId>
  <artifactId>cxf-rt-rs-extension-providers</artifactId>
  <version>2.7.7</version>
</dependency>
-5
votes

Tomcat 7 should not require RESTEasy, Jersey or any other proprietary implementation if JAX-RS is an integral part of Java EE 6 web-profile, which it is.