12

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.

1

5 Answers 5

1

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

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

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

tomcat 7.0.29

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

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.

2
  • 1
    Tomcat 7 isn't web profile, TomEE is 'an all-Apache stack aimed at Java EE 6 Web Profile certification', but doesn't contain JAXRS. The one you need is TomEE+ [tomee.apache.org/apache-tomee.html]
    – user484261
    Dec 5, 2013 at 14:17
  • WRONG, Tomcat 7 does not contain JAX-RS RI
    – ACV
    Apr 7, 2015 at 21:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.