Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Tomcat7 working with JAX-RS?

Tags:

jax-rs

tomcat7

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.

like image 654
Artilheiro Avatar asked Mar 28 '11 18:03

Artilheiro


People also ask

Does Tomcat support JAX-RS?

JAX-RS applications are deployed within a standalone servlet container, like Apache Tomcat, Jetty, JBossWeb, or the servlet container of your favorite application server, like JBoss, Wildfly, Weblogic, Websphere, or Glassfish.

What can a JAX-RS method return?

If the URI path template variable cannot be cast to the specified type, the JAX-RS runtime returns an HTTP 400 (“Bad Request”) error to the client. If the @PathParam annotation cannot be cast to the specified type, the JAX-RS runtime returns an HTTP 404 (“Not Found”) error to the client.

What is the purpose of using JAX-RS?

The aim of JAX-RS is to make development of Java Web services built according to the Representational State Transfer (REST) architectural style both straightforward and natural for you, the developer.


2 Answers

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

like image 149
alokoko Avatar answered Oct 26 '22 16:10

alokoko


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
like image 39
freedev Avatar answered Oct 26 '22 17:10

freedev