Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When to use javax.ws.rs.core.Application to create RESTful web services?

I have developed RESTful web services in two ways:

  1. used a class that extends javax.ws.rs.core.Application without defining a web.xml file, using Glassfish.

  2. haven't used javax.ws.rs.core.Application but included a web.xml and a Jersey implementation, using Tomcat.

Is there a preferred way of building RESTful web services with JAX-RS?

like image 726
Sameer Sarmah Avatar asked Aug 21 '14 05:08

Sameer Sarmah


1 Answers

Using the javax.ws.rs.core.Application class is the preferred way and also the only portable way of configuring resources and providers in a JAX-RS web service, so if possible that would be the recommended way to set it up.

But that works well only in JAX-RS aware servlet containers or application servers, for JAX-RS non aware servers you need other ways for deployment and that most of the times means some proprietary servlet class of the JAX-RS implementation you are using.

To get more details on the subject, see for example the Jersey documentation, Deploying a RESTful Web Service (for Jersey v1.x) and Application Deployment and Runtime Environments (for Jersey v2.x).

like image 187
Bogdan Avatar answered Sep 28 '22 04:09

Bogdan