8 Replies Latest reply on Oct 15, 2007 10:05 AM by psternon

    EntityManager null

    srpantano

      I made:

      <component name="em" auto-create="true" class="org.jboss.seam.core.ManagedPersistenceContext">
       <property name="persistenceUnitJndiName">java:/data</property>
       </component>
      
       <component name="org.jboss.seam.ui.entityConverter">
       <property name="entityManager">#{em}</property>
       </component>
      
       <component name="roles" class="org.jboss.seam.framework.EntityQuery">
       <property name="ejbql">select r from Role r</property>
       </component>
      


      but when I run the facelet page with:
      <h:selectOneMenu value="#{list.roles}" required="true">
       <s:selectItems value="#{roles.resultList}" var="role" label="#{role.descricao}" noSelectionLabel="Please Select..."/>
       <s:convertEntity />
       </h:selectOneMenu>
      


      but the result is:
      java.lang.IllegalStateException: entityManager is null

      please, I´m missing something?

      PS.: I´m using Seam 1.2.1GA, Jboss 4.2.0ga and facelets 1.12

        • 1. Re: EntityManager null

          change name from "em" to "entityManager"

          I don't know why, but Seam hard codes to look for "entityManager" .

          • 2. Re: EntityManager null
            srpantano

            Works fine, thanks!


            But, this is a bug, doesn´t it?

            • 3. Re: EntityManager null
              gavin.king

              It is not hardcoded, it is a default, which may be configured in components.xml!

              • 4. Re: EntityManager null
                davidjoseph

                This is a bug!

                This is what it says in the most recent reference documentation:

                If your Managed Persistence Context isn't called entityManager, then you need to set it in components.xml:
                
                <component name="org.jboss.seam.ui.EntityConverter">
                <property name="entityManager">#{em}</property>
                </component>


                But first of all,

                it is not org.jboss.seam.ui.EntityConverter but org.jboss.seam.ui.converter.EntityConverter

                And second of all: it is impossible to use another name for the entitymanager as specified in the documentation. I've tried everyting. The only possible way to make this work is to changer every em reference in you code to entityManager. This can not be hardcoded! The is a SERIOUS BUG

                • 5. Re: EntityManager null
                  christian.bauer

                  OMG!

                  • 6. Re: EntityManager null
                    davidjoseph

                    very funny

                    I've been trying to get Seam up and running here at our company for some quite some time now, but I'm often confronted with those kind of annoying little things. I do appreciate the help I get here but do not have the time to check the forum all the time for help on all these configuration issues. I think i'll try again in a year or so...

                    • 7. Re: EntityManager null
                      pmuir

                      Actually, org.jboss.seam.ui.EntityConverter is correct.

                      And, yes, it does work as described in reference manual (i just checked) so no serious bug just serious user error.

                      You should have a read of http://en.wikipedia.org/wiki/Software_release_cycle#Beta as well, should be enlightening.

                      • 8. Re: EntityManager null
                        psternon

                        you probably have a exception about the rendering of the <h:selectOneMenu.
                        Replace that by a trinidad component.
                        We had the same issue and that fixed our issue