users@jersey.java.net

Re: [Jersey] Jersey and Spring

From: Martin Grotzke <martin.grotzke_at_freiheit.com>
Date: Mon, 07 Jul 2008 16:10:29 +0200

On Mon, 2008-07-07 at 12:11 +0200, Lars Tackmann wrote:
> On Mon, Jul 7, 2008 at 10:24 AM, Martin Grotzke
> <martin.grotzke_at_freiheit.com> wrote:
> > Hi Lars,
> >
> > I would say that your UsersResource is not set up correctly: I'd say
> > that it is not create by spring and therefore the UserManager should not
> > be injected. That you receive status 200 all the time sounds really
> > weird to me!
> >
> > But let's first check if your UsersResource is set up as expected.
> > Can you please check, if the UserManager is already injected? If not,
> > you should add @Component to your UsersResource, so that spring is aware
> > of this class.
>
> HI and thanks for the feedback.
>
> Some real bad code from my part, made the code swollow a null pointer
> exception (why this results in 200 is still a mystery though).
Can you create some really, really simple resource that shows this issue
and send this again, or perhaps directly submit an issue for this?

> it turned out that I had to annotate the resource with;
>
> --
> @PerRequest
> @Component
> @Scope( "prototype" )
> --
>
> I can understand the component part, but having to use springs @Scope
> annotation is overkill (at least when one also uses Jersey's lifecycle
> annotations).
Why do you want to have a prototype there? AFAICS you should be able to
use a singleton resource, which is the default scope of both jersey and
spring.

>
> Anyway thanks for the help. I suspect I will have a complete mavenised
> Spring/Jersey sample ready in a couple of days (integrated with Spring
> security 2) - I will gladly post it here, so others can benefit from
> it (perhaps it can go into jersey's example folder).
Sound good, this would be great! :)

Cheers,
Martin