2 Replies Latest reply on Sep 6, 2006 4:01 AM by cvirko

    Seam-managed persistence context set-up in Tomcat - help

    cvirko

      Does anyone have experience with setting up Seam-managed persistence context set-up in Tomcat? I just don't know how to set up EntityManagerFactory in Tomcat.

      Another question is what is the difference between

      @In(create=true) EntityManager bookingDatabase;

      and

      @PersistenceContext(unitName="booking") private EntityManager bookingDatabase;

      Thanks

      Tomas

        • 1. Re: Seam-managed persistence context set-up in Tomcat - help
          baz

           

          Does anyone have experience with setting up Seam-managed persistence context set-up in Tomcat?

          Do you want to use embedded EJB or do you want a Hibernate session in a microcontainer. The later is described in the seam docu and there is the hibernate example in the seam distribution. The first is also described in the docu .
          Please take the time to set up an respective example and try to run it. This should solve your problem. If you have deeper understanding what is going on do not hesitate to ask again.

          Another question is what is the difference between

          @In(create=true) EntityManager bookingDatabase;

          and

          @PersistenceContext(unitName="booking") private EntityManager bookingDatabase;

          Look here:
          http://www.jboss.com/index.html?module=bb&op=viewtopic&t=70997
          Ciao,
          Carsten

          • 2. Re: Seam-managed persistence context set-up in Tomcat - help
            cvirko

            I want to use JPA with Hibernate, Seam, JSF RI 1.2 Facelets and Tomcat. I want to use JavaBean, no Session Beans. I have everything set up. I am just struggling with Persistence Context. My persistence.xml is

            <persistence>
             <persistence-unit name="fossEntityManager">
             <provider>org.hibernate.ejb.HibernatePersistences</provider>
             <jta-data-source>java:/fossDatasource</jta-data-source>
             <properties>
             <property name="hibernate.show_sql" value="true"/>
             </properties>
             <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
             <property name="jboss.entity.manager.factory.jndi.name" value="java:/fossEntityManagerFactory"/>
             </persistence-unit>
            </persistence>
            


            My components.xml file is
            <components>
             <component name="org.jboss.seam.core.init">
             <property name="myFacesLifecycleBug">false</property>
             <property name="jndiPattern">#{ejbName}/local</property>
             </component>
            
             <component class="org.jboss.seam.core.Microcontainer" installed="true"/>
            
             <component name="org.jboss.seam.core.init.managedPersistenceContexts">fossEntityManager</component>
            
             <component class="org.jboss.seam.core.Ejb" installed="true"/>
            
             <!-- Added Seam-managed persistence context -->
             <component name="fossEntityManager"
             class="org.jboss.seam.core.ManagedPersistenceContext">
             <property name="persistenceUnitJndiName">java:/fossEntityManagerFactory</property>
             </component>
            </components>
            


            I even added

            <component name="org.jboss.seam.core.init.managedPersistenceContexts">fossEntityManager</component>


            And then in my JavaBean class I have following line

            @In(create=true) EntityManager fossEntityManager;


            and I am still getting error:

            java.lang.IllegalArgumentException: EntityManagerFactory not found
            ...
            Caused by: javax.naming.NameNotFoundException: fossEntityManagerFactory not bound
            


            What am I doing wrong. I though that microcontainer would take care of JNDI mapping. Where else am I suposed to register EntityManagerFactory?

            I was using

            Perstince.createEntityManagerFactory(
             "fossEntityManager")


            and it worked fine. However, I would like to use Seam-managed PC. Any help appreciated. Thanks

            Tomas