1 Reply Latest reply on Apr 28, 2010 10:18 PM by Gary Habura

    Glassfish v3 Resource injection

    Gary Habura Newbie

      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:

      public class CountryService implements Serializable{
           private EntityManager entityManager;
           public CountryService() {
              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.

      public class PageBean implements Serializable {
          private CountryService countryService;
           public PageBean() {

      It get an UnserializableDependencyException when I try to @Inject a @Stateless EJB.

      Am I doing something wrong or is Glassfish just broke?