users@glassfish.java.net

Injection problems with GF4 and Jersey2

From: Jan Algermissen <jan.algermissen_at_nordsc.com>
Date: Fri, 5 Oct 2012 16:14:50 +0200

Hi,

I am having trouble injecting into a message body writer.

Is it possible that the combination of Glassfish and Jersey 2 as described here

https://blogs.oracle.com/arungupta/entry/jersey_2_in_glassfish_4

messes up injection?

In resource classes I can only get injection to work by making the class @Stateless and injecting via @EJB (injected class is an EJB singleton).

In my message body writer I cannot get injection to work at all. Note even with @Stateless and @EJB, as in

@Provider
@Stateless
public class MyMBR implements MessageBodyWriter<Customer> {
        
        @EJB
        MyService myService;

       ...
}

(I have a beans.xml ... )


Jan