users@jersey.java.net

Re: [Jersey] Jersey and Spring

From: Matt Brozowski <brozow_at_opennms.org>
Date: Mon, 7 Jul 2008 14:44:43 -0400

I am also working on a Sample App that's using Spring and Jersey and have
found only one bug. I've only been working on it a few days but it is here:

http://opennms.svn.sourceforge.net/svnroot/opennms/playground/brozow/expenses/

It uses Jersey, Spring and Hibernate as well as Maven2 for building. I also
intend for it be both a web service AND a web app using the same resources.

I have also written a ModelAndViewWriter for using Spring's View classes to
generate view content.

The one bug I did find in the SpringServlet is related to excpetion
handling. It fails to pass RuntimeException up the servlet container as the
spec specifies it should. I have included a Hack that resolves this but it
would be nice to get the real. Therefore if an exception occurs that has no
mapping only a blank web page is shown with no content. Rather than allowing
the container to use its default mechanism.

Any simple way to report bugs on this?

Matt Brozowski




On Mon, Jul 7, 2008 at 10:10 AM, Martin Grotzke <martin.grotzke_at_freiheit.com>
wrote:

> 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
>
>
>