3 Replies Latest reply on Mar 8, 2007 5:48 AM by Gianni

    SeamEntityConverter - Cannot access entityManager

    Gianni Newbie

      Just starting out with EJB3 and Seam ....
      I have followed the Wiki instructions for using s:selectItems with the SeamEntityConverter to populate a select menu, the menu is populated correctly but when I sumbit the form I get a Faces Message:
      "Cannot access entityManager; Either use the default name (entityManager) for your entity manager or specify it in components.xml"

      I do have the entity manager specified in components.xml:

      auto-create="true" />

      <h:selectOneMenu value="#{appUser.title}"
      id="usertitle" required="true" >
      <s:selectItems value="#{personTitles}"
      hideNoSelectionLabel="true" />
      <ec:convertEntity />

      Seam version: 1.2.0.PATCH1

      Not sure where to go next and I'd appreciate it if someone could point me in the right direction.

        • 1. Re: SeamEntityConverter - Cannot access entityManager
          Pete Muir Master

          So an @In EntityManager entityManager works for you inside a Seam component?

          • 2. Re: SeamEntityConverter - Cannot access entityManager
            Pete Muir Master

            Yeah, so that error message is not very helpful :(

            Try putting a breakpoint on the loadEntityFromPersistenceContext in AbstractEntityConverter and track down what the actual exception thrown is.

            • 3. Re: SeamEntityConverter - Cannot access entityManager
              Gianni Newbie

              Thanks, after trying to inject EntityManager with "@In EntityManager entityManager" I can see it's a problem with the JNDI binding.

              I'm running on Glassfish and I've tried the following:

              <core:managed-persistence-context name="entityManager"
              auto-create="true" />

              in web.xml

              <persistence-unit name="Orpello-PU" transaction-type="JTA">

              .. and i get

              Caused by: javax.naming.NameNotFoundException: No object bound to name java:comp/env/persistence/Orpello-PU
              at com.sun.enterprise.naming.NamingManagerImpl.lookup(NamingManagerImpl.java:751)
              at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:156)
              at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:307)
              at javax.naming.InitialContext.lookup(InitialContext.java:392)
              at org.jboss.seam.core.ManagedPersistenceContext.getEntityManagerFactoryFromJndiOrValueBinding(ManagedPersistenceContext.java:160)
              ... 115 more

              Maybe getting a bit off-topic here but can anyone help on how I should bind the entity manager into JNDI in Glassfish?
              From what I have read the <persistence-context-ref> in web.xml should do it.