users@jersey.java.net

Re: [Jersey] Spring and XmlWebApplicationContext

From: Martin Grotzke <martin.grotzke_at_freiheit.com>
Date: Tue, 10 Mar 2009 11:49:50 +0100

Hi,

On Mon, 2009-03-09 at 17:43 +0100, Paul Sandoz wrote:
> Hi Martin, Jens,
>
> Could things be related to the following issue:
>
> https://jersey.dev.java.net/issues/show_bug.cgi?id=222
yes, might be related to it. Jens, what do you say, what's your setup?

>
> Martin, the patch supplied with the issue looks good, but if you have
> time could you look at it, also any hints help on writing unit tests
> for it would be most helpful.
+1 for having a test for this.

Personally I would prefer to ask the beanFactory with
beanFactory.containsBeanDefinition over the handled exception in
scanForBeanDefinition, but that's just my preference :)

Cheers,
Martin


>
> Paul.
>
> On Mar 4, 2009, at 11:06 PM, Martin Grotzke wrote:
>
> > Hi,
> >
> > I just modified the spring-annotations sample to use a custom
> > SpringServiceApplicationContext that inherits from
> > XmlWebApplicationContext, as you described. I also added a resource
> > class with a field annotated with @Inject, of a type that has a bean
> > definition in the applicationContext.
> >
> > The SpringServiceApplicationContext is created and getBean(String
> > name,
> > Class requiredType) method is invoked as expected. So I can't
> > reproduce
> > your issue.
> >
> > The spring-annotations sample is using the spring
> > ContextLoaderListener
> > and the jersey SpringServlet as a servlet.
> >
> > What's your setup? Can you provide more code to reproduce?
> >
> > Cheers,
> > Martin
> >
> >
> > On Wed, 2009-03-04 at 12:08 +0100, mailinglist_at_j-b-s.de wrote:
> >> Hi!
> >>
> >> I am new to Jersey and got a problem concerning "@Inject" of spring
> >> beans in my Jersey sample app. We use our own Web app context class
> >> which is directly derived from Springs XmlWebApplicationContext.
> >> When the application starts the context gets properly initialized
> >> so it is not a problem of the web.xml (well, it looks like not to
> >> be :-).
> >> ...
> >> <context-param>
> >> <param-name>contextClass</param-name>
> >> <param-value>testpackage.SpringServiceApplicationContext</param-
> >> value>
> >> </context-param>
> >> ...
> >> so using this entry in web.xml the spring context is initialized.
> >>
> >>
> >> Unfortunately no call from Jersey to one of the getBean methods
> >> happens, so it seems the @Inject is silently ignored. Can anyone
> >> give me a litte hint or point my in the right direction? Is there a
> >> special prop/setting where I can tell jersey to map "@inject" to
> >> "please use the SpringServiceApplicationContext" to retrieve the
> >> beans?
> >>
> >>
> >> Thanks in advance
> >>
> >> Jens
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> >> For additional commands, e-mail: users-help_at_jersey.dev.java.net
> >
> > --
> > Martin Grotzke
> > http://www.javakaffee.de/blog/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net