I'm working with CR2, focusing on unit test mode.  I've included the 
embedded-ejb stuff in my classpath.  When I run a unit test, SeamTest's init() 
method fails, because the persistenceUnit property on the EntityManagerFactory 
hasn't been set (and so defaults to the component's name, which doesn't match 
the persistence.xml).

In the debugger if I set the persistenceUnit property of EntityManagerFactory 
to the correct name (feedbuilders in this case) the test runs correctly.  
Section 3.3.2 of the docs discusses configuring components through the 
components.xml, but I'm not sure how this default value should be set 
correctly.  The examples seem to run, so obviously I'm missing something.  Any 
suggestions?

Here's the exception I'm seeing:


  | javax.persistence.PersistenceException: No Persistence provider for 
EntityManager named org.jboss.seam.core.EntityManagerFactory
  |     at 
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:41)
  |     at 
org.jboss.seam.core.EntityManagerFactory.startup(EntityManagerFactory.java:74)
  |     at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
  |     at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:102)
  |     at org.jboss.seam.Component.callComponentMethod(Component.java:1774)
  |     at org.jboss.seam.Component.callCreateMethod(Component.java:1714)
  |     at org.jboss.seam.Component.newInstance(Component.java:1703)
  |     at org.jboss.seam.contexts.Lifecycle.startup(Lifecycle.java:153)
  |     at 
org.jboss.seam.contexts.Lifecycle.endInitialization(Lifecycle.java:127)
  |     at org.jboss.seam.init.Initialization.init(Initialization.java:430)
  |     at org.jboss.seam.mock.SeamTest.init(SeamTest.java:686)
  | 

Here's the first bit from my unit test.  em() never gets called though since 
it's failing in super.init()


  | public class FeedDataTest extends SeamTest
  | {
  |     EntityManager em() {
  |         EntityManagerFactory emf = 
Persistence.createEntityManagerFactory("feedbuilders");
  |         EntityManager        em  = emf.createEntityManager();
  |         assertNotNull("entity manager", em);
  |         assertTrue("entity manager open", em.isOpen());
  |         return em;
  |     }
  | 

Here's the meat of my components.xml:


  | <core:init debug="true" jndi-pattern="#{ejbName}/local"/>
  | 
  | <!-- 120 second conversation timeout -->
  | <core:manager conversation-timeout="120000"/>
  | 
  | <core:ejb installed="true"/>
  | 
  | <core:entity-manager-factory 
jndi-name="java:/feedbuildersEntityManagerFactory" />
  | 

And here's persistence.xml, which defines the "feedbuilders" unit name (that 
doesn't get set in the EntityManagerFactory during init():


  | <persistence>
  |     <persistence-unit name="feedbuilders">
  |       <provider>org.hibernate.ejb.HibernatePersistence</provider>
  |       <jta-data-source>java:/feedbuildersDatasource</jta-data-source>
  |       <properties>
  |          <property name="hibernate.hbm2ddl.auto" value="create"/>
  |          <property name="hibernate.cache.use_query_cache" value="true"/>
  |          <property name="hibernate.show_sql" value="true"/>
  |          <property name="jboss.entity.manager.factory.jndi.name" 
value="java:/feedbuildersEntityManagerFactory"/>
  |       </properties>
  |     </persistence-unit>
  | </persistence>
  | 

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

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3989016
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to