I have a stateless EJB that acceses my database. I need this bean in a JSF 2 converter to retreive an entity object from the String value parameter. I'm using JEE6 with Glassfish V3.
@EJB
annotation does not work and gets a NPE, because it's in the faces context and it has not access to the EJB context.
My question is:
Is it still possible to Inject this bean with a @Resource
or other annotation, or a JNDI lookup, or do I need a workaround?
Solution
Do a JNDI lookup like this:
try {
ic = new InitialContext();
myejb= (MyEJB) ic
.lookup("java:global/xxxx/MyEJB");
} catch (NamingException e) {
e.printStackTrace();
}