5

As of my understanding java EE application servers have mainly two types of containers. Namely web container and EJB container.

I managed to run a JAX-RS application which used Jersey as its implementation, in Tomcat. As I know Tomcat is only a web container. In order to run the web service in tomcat, the jersey jars had to be bundled into the war file because out of the box, Tomcat did not have the jersey jars. This raised me a question.

Does tomcat uses another implementation of JAX-RS other than Jersey? If Yes what is it?

if No,

I could not run the Jax-RS application without the jars bundled into the war file, this means JAX-RS apps need something more than what the web containers offer. It means they do not run in a web container. then in which container does it run?

Paul Samsotha
  • 205,037
  • 37
  • 486
  • 720
DesirePRG
  • 6,122
  • 15
  • 69
  • 114
  • JAX-RS applications need - of course - the JAX-RS API. This doesn't mean the JAX-RS-resources don't run in the web container. – isnot2bad May 01 '15 at 13:20
  • why didn't Tomcat come built in with the JAX-RS API and its implementation – DesirePRG May 01 '15 at 13:23
  • Good question. On the one hand, JAX-RS is part of the Java EE web profile. But on the other hand, Apache Tomcat does not claim to be fully compatible to this profile - it only claims to be an Java Servlet/JSP container. – isnot2bad May 01 '15 at 13:28
  • any web profile implementations out there? – DesirePRG May 01 '15 at 13:36
  • TomEE is such one. WildFly is another one. There are more, but not as popular. – BalusC May 01 '15 at 14:15
  • I downloaded TomEE, but unable to find the JAX-RS jar in its lib folder – DesirePRG May 01 '15 at 14:39
  • Turns out TomcatEE web profile does not include JAX-RS. there is another version which includes it named TomEE JAXRS – DesirePRG May 01 '15 at 14:44
  • 1
    Yeah I should've mentioned it's TomEE+. You may want to keep the [CXF documentation](http://cxf.apache.org/docs/jax-rs.html) handy if you're going to use TomEE. Though JAX-RS is a standard, different implementation have different features and configurations available. JAX-RS as a spec, is limited in it's configurations. – Paul Samsotha May 01 '15 at 14:59

1 Answers1

9

"Does tomcat uses another implementation of JAX-RS other than Jersey?"

I don't know if you're asking if Tomcat has an implementation or if it is capable of running other implementations beside Jersey.

The answer to the former is no. Vanilla Tomcat does not support JAX-RS out the box. It is not an EE server, but simply a Servlet container. But TomEE+ (built on Tomcat) has support (using CXF).

The answer to the latter is yes. You just need to add that implementations jars and configure the app properly

"I could not run the Jax-RS application without the jars bundled into the war file"

Yup, you can't. For the simple fact there is no implementation to support the JAX-RS runtime.

"It means they do not run in a web container. then in which container does it run?"

It does run in the Servlet container. JAX-RS is actually built on top of Servlets. For Jersey, it uses the ServletContainer. Tomcat will ship off requests to the Jersey Servlet, and Jersey will process the request through configured provider and resources and spit out the response back to the container. The container will send the response to the client. (See first link below)


If you are looking for a Java EE application server, that supports the whole EE spec, you can look at Glassfish (it uses Jersey as it's implementation), JBoss/Wildfly (it uses Resteasy), TomEE+ mentioned above (uses CXF)


Here are some related reads you might find interesting:

Community
  • 1
  • 1
Paul Samsotha
  • 205,037
  • 37
  • 486
  • 720