users@jersey.java.net

Jersey injection into spring managed beans

From: Camel Christophe <ccamel_at_cls.fr>
Date: Mon, 14 Jun 2010 17:21:57 +0200

Hello everybody,

I'm using Jersey and I'm facing the following issue. When declaring a
bean as a service with the @Service annotation, I would like to inject
Jersey information into a field of that bean, like this:

@Service
public class AService {

    /**
     * I expect this field to be valuated automagically by jersey.
     */
    @Context
    private WadlApplicationContext wadlContext;

    public void foo() {
      if( wadlContext == null ) {
           System.out.println( "doesn't work");
      } else
      {
           System.out.println( "cool !");
      }
    }
}

But this doesn't work: the wadlContext is always null. Moreover, It's
always the case with all jersey injectable properties.

What should I do to make it work properly ?

I'm using Jersey 1.0.3.1. I declare the spring servlet from
jersey-spring package in my web.xml. Everything works fine except spring
injection into full spring beans.

Thanks for any help.