users@jersey.java.net

RE: [Jersey] Jersey ignores javax.ws.rs.core.Application

From: Gili <cowwoc_at_bbs.darktech.org>
Date: Thu, 2 Oct 2008 20:50:37 -0700 (PDT)

That's what I thought too, that you had to specify it by hand. Oddly enough,
this is the only Jersey-related thing I have in web.xml:

        <servlet>
                <servlet-name>ServletAdaptor</servlet-name>
        
<servlet-class>com.sun.jersey.spi.guice.container.servlet.GuiceServlet</servlet-class>
                <init-param>
                        <param-name>moduleClass</param-name>
                        <param-value>method.adcaster.guice.Module</param-value>
                </init-param>
                <load-on-startup>1</load-on-startup>
        </servlet>
        <servlet-mapping>
                <servlet-name>ServletAdaptor</servlet-name>
                <url-pattern>/*</url-pattern>
        </servlet-mapping>

and it finds all the classes automatically. Nowhere do I specify a package
name or list out my classes.

Gili


Alex Sherwin wrote:
>
> I could be mistaken, but I'm using the init params:
>
> <init-param>
>
> <param-name>com.sun.jersey.config.property.resourceConfigClass</param-name>
>
> <param-value>com.sun.jersey.api.core.PackagesResourceConfig</param-value>
> </init-param>
> <init-param>
> <param-name>com.sun.jersey.config.property.packages</param-name>
> <param-value>com.your.package1;com.your.package2</param-value>
> </init-param>
>
> Which tells Jersey what packages to search for annotated JAX-RS impl
> classes. I just read through the JSR tonight and I got out of it that
> classes annotated with @Path, @Resource (and a few other key annotations)
> will be found in this manner.
>
> I don't know how it would find them if you were not using that type of
> Servlet config, though. But, for example, in the demo apps that use the
> lightweight http server, when building the container one of the methods
> you
> call takes a variable (Class ...) argument that you pass in a list of the
> resources, providers etc you want Jersey to find.
>
>
> Alex Sherwin
> alex.sherwin_at_acadiasoft.com
>
> -----Original Message-----
> From: Gili [mailto:cowwoc_at_bbs.darktech.org]
> Sent: Thursday, October 02, 2008 11:40 PM
> To: users_at_jersey.dev.java.net
> Subject: Re: [Jersey] Jersey ignores javax.ws.rs.core.Application
>
>
> I'm curious... how does the current Jersey implementation automatically
> locate all classes annotated with @Provider? Last I checked it wasn't easy
> to do that sort of thing (finding all classes in the classpath or module).
>
> Gili
>
>
> Paul Sandoz wrote:
>>
>> Hi Gili,
>>
>> Section 2.3.2 of JSR-311 states:
>>
>> When using a JAX-RS aware servlet container, the servlet-class
>> element of the web.xml descriptor
>> SHOULD name the application-supplied subclass of Application.
>>
>> What is written in the article is not specified by JSR-311 and is non-
>> standard behaviour.
>>
>> However, Jersey does not currently support what is specified above
>> because we need to make modifications to the Servlet implementation.
>>
>> Paul.
>>
>> On Sep 29, 2008, at 9:31 PM, Gili wrote:
>>
>>>
>>> Hi,
>>>
>>> I fired up Netbeans 6.5, created a RESTful web service and added the
>>> following to my web.xml:
>>>
>>> <context-param>
>>> <param-name>javax.ws.rs.core.Application</param-name>
>>> <param-value>method.adcaster.network.Application</param-value>
>>> </context-param>
>>>
>>> According to http://architects.dzone.com/articles/putting-java-rest
>>> JAX-RS
>>> should use this class to detect all my services, but Jersey seems to
>>> ignore
>>> it and parses *all* classes instead.
>>>
>>> Did I miss something?
>>>
>>> Thank you,
>>> Gili
>>> --
>>> View this message in context:
>>>
> http://n2.nabble.com/Jersey-ignores-javax.ws.rs.core.Application-tp1127216p1
> 127216.html
>>> Sent from the Jersey mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>>
>>
>
> --
> View this message in context:
> http://n2.nabble.com/Jersey-ignores-javax.ws.rs.core.Application-tp1127216p1
> 140761.html
> Sent from the Jersey mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>
>

-- 
View this message in context: http://n2.nabble.com/Jersey-ignores-javax.ws.rs.core.Application-tp1127216p1140778.html
Sent from the Jersey mailing list archive at Nabble.com.