[jboss-user] [JBoss Seam] - Re: Seam-managed persistence context set-up in Tomcat - help

Cvirko do-not-reply at jboss.com
Wed Sep 6 04:01:35 EDT 2006


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

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3969657#3969657

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3969657



More information about the jboss-user mailing list