On 4 May 2010 09:33, Paul Sandoz <Paul.Sandoz_at_sun.com> wrote:
> Hi Adam,
>
> Can you send me the output of the server log on deployment?
>
> Does UriInfo get injected?
Yes it does, its just the global ParthParams that are null.
> What is the scope of CareAgencyResource? have you declared it to be a spring
> bean in the XML configuration? By default spring managed beans are
> singletons.
> If the scope is a singleton then @PathParam annotations will not get
> injected. You need to modify the scope to be per request.
It was the default scope, I did not realise that I needed to change
it. Now that you mention it, of course it makes sense :-) After
changing the bean to scope="request" all works as expected.
Although I also needed to add this to web.xml as the request scope is
outside of Springs Dispatcher servlet -
<listener> <!-- needed for Request scoped Spring beans that are
outside the spring web context - e.g. Jersey -->
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
It would be really good to get those two pieces of information added
to Jerseys spring integration documentation, all I could find was this
-
https://jersey.dev.java.net/nonav/documentation/latest/user-guide.html#d4e1280
https://jersey.dev.java.net/nonav/apidocs/1.1.5.1/contribs/jersey-spring/com/sun/jersey/spi/spring/container/servlet/package-summary.html
> Ideally Jersey should throw a deployment-based exception when such injection
> cannot be performed. Can you log an issue?
Sure, I have added an Enhancement request, as issue 524.
Thanks Adam.
> Thanks,
> Paul.
>
> On May 3, 2010, at 8:08 PM, Adam Retter wrote:
>
>> I have had some success but still some issues -
>>
>>> <dependency>
>>> <groupId>com.sun.jersey.contribs</groupId>
>>> <artifactId>jersey-spring</artifactId>
>>> <version>1.1.5</version>
>>> <exclusions>
>>
>> I needed to add the additional exclusion -
>>
>> <exclusion>
>> <groupId>org.springframework</groupId>
>> <artifactId>spring-web</artifactId>
>> </exclusion>
>>
>>
>> But the problem is now, that when I use my Jersey REST Services inside
>> Spring, any global PathParam(s) are no longer injected, for example
>> with this style class -
>>
>> @Path("/careAgency/{careAgencyId}")
>> public class CareAgencyResource {
>>
>> @Context UriInfo uriInfo;
>> @PathParam("careAgencyId") private Integer careAgencyId;
>>
>> @GET
>> @Path("logo")
>> @Produces("image/*")
>> public Response getLogoResource()
>> {
>> //code goes here
>> }
>> }
>>
>> For example with this URL -
>> http://localhost:8084/AccountableCare/resources/careAgency/1/logo
>>
>> The variable careAgencyId is always null. :-(
>> When I was using Jersey outside of Spring, it all worked. However, it
>> was a complete nightmare trying to access my spring managed beans from
>> inside my Jersey REST classes.
>>
>> Any ideas if there is a bug in global PathParam injection when using
>> Spring with Jersey?
>>
>>
>> --
>> Adam Retter
>>
>> skype :adam.retter
>> http://www.adamretter.org.uk
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: dev-help_at_jersey.dev.java.net
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: dev-help_at_jersey.dev.java.net
>
>
--
Adam Retter
skype :adam.retter
http://www.adamretter.org.uk