Is anyone using Glassfish v3 and successfully injecting a JEE Resource into a managed bean?
I cannot get a PeristenceUnit injected into ManagedBean.
I have the following bean:
@Named public class CountryService implements Serializable{ @PersistenceUnit(unitName="reference-businesstier") private EntityManager entityManager; public CountryService() { super(); } public List<Country> getCountries(){ return entityManager.createNamedQuery(FIND_ALL).getResultList(); } }
This is deployed in reference.jar. The META-INF of the JAR has the beans.xml and persistence.xml files accordingly.
If I change @Named to @Stateless, the peristence context is injected and the query is executed.
Another issue I am having is when I @Inject the above bean as an EJB into the SessionScope Page Bean.
@SessionScoped public class PageBean implements Serializable { @Inject private CountryService countryService; public PageBean() { super(); } }
It get an UnserializableDependencyException when I try to @Inject a @Stateless EJB.
Am I doing something wrong or is Glassfish just broke?