Skip to main content

Injection problems with GF4 and Jersey2

1 reply [Last post]
Anonymous

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 {

@EJB
MyService myService;

...
}

(I have a beans.xml ... )

Jan

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Algermissen, Jan (TALENTFORMATION)

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 {

@EJB
MyService myService;

...
}

(I have a beans.xml ... )

Jan