users@jersey.java.net

Re: [Jersey] Explicit registration of Jersey servlet ?

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Thu, 18 Feb 2010 16:28:44 +0100

On Feb 18, 2010, at 4:10 PM, Arun Gupta wrote:
>
>>> This is deployed as simplewebapp.war on GlassFish v3.
>>>
>>> http://localhost:8080/simplewebapp/actor/4
>>>
>> I am not sure what a "simplewebapp.war" is, but i think i can guess
>> it is one that has no web.xml?
> Yep, just the resource class and no web.xml.
>
>> Assuming that is the case you need to include the following:
>> @ApplicationPath("/sakila")
>> public class MyApplication extends Application {
>> }
>> An implementation of Application is required for inform Jersey what
>> root resource and provider classes are registered. If you do not
>> override any of the methods then all classes annotationed with
>> @Path and @Provider will be included.
> JSF registers FacesServlet by scanning through all the classes and
> looking for @ManagedBean or any of the JSF annotations and then
> automatically registered. I was wondering if Jersey could register
> the servlet that way as well instead of providing an extra marker
> class.
>

A marker class, annotated with ApplicationPath, is required to specify
the base path [*] of the URI:

   http://foo:8080/<context path>/<base path>/stuff

We did not want to specify a default base path in JAX-RS.

Paul.

[*] the servlet URL pattern is derived form that