users@jersey.java.net

Re: [Jersey] Spring and XmlWebApplicationContext

From: Martin Grotzke <martin.grotzke_at_freiheit.com>
Date: Wed, 04 Mar 2009 23:06:26 +0100

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/