Skip to main content

Glassfish 4 + Jersey filter with @EJB

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
No replies
andre.imm
Offline
Joined: 2013-07-29

Hi guys.

I'm developing an REST application using Glassfish 4.0. I'm using JAX-RS filters and I'm trying to use an EJB in the filter. The bean with @EJB annotation works on any REST resource in the project, except on the filter.

See code below:

######### MyBean #########

@Remote
public interface MyBeanInterface {
String getStuff();
}

-----

@Stateless
public class MyBean implements MyBeanInterface {

@Override
public String getStuff() {
return "stuff done";
}
}

######### Filter #########

@Provider
public class UpdateFilter implements ContainerRequestFilter {

@EJB
private MyBeanInterface doStuffBean;

@Override
public void filter(ContainerRequestContext requestContext) {
....
}
}

####################

"doStuffBean" is always null.

Can anyone help me?