[jboss-user] [JBoss Seam] - Re: Test EJB3/Seam from eclipse

jfrankman do-not-reply at jboss.com
Fri May 18 19:14:25 EDT 2007

I will answer my own question concerning my "emf = Persistence.createEntityManagerFactory("myResourceLocalEntityManager");" question.

I just had to define the persistence-unit in a persistence.xml file. 

      <persistence-unit name="sample">
  |       <provider>org.hibernate.ejb.HibernatePersistence</provider>
  |             <class>com.idfbins.nexus.common.vo.busent.FBWorker</class>
  |             <properties>
  |                   <property name="hibernate.connection.driver_class" value="com.ibm.db2.jcc.DB2Driver"/>
  |                   <property name="hibernate.connection.username" value="db2admin"/>
  |                   <property name="hibernate.connection.password" value="db2admin"/>
  |                   <property name="hibernate.connection.url" value="jdbc:db2://nexusdbtest:50001/nxsprot1"/>
  | 			      <property name="hibernate.dialect" value="org.hibernate.dialect.DB2Dialect"/>          
  |             </properties>
  |       </persistence-unit>

If I understand this correctly, EJB3 requires the persistence.xml file to exist in the META-INF directory. Seam-gen creates three separate persistence files: persistence-dev.xml, persistence-test.xml, and persistence-prod.xml. It then copies one of these into the META-INF directory from the ANT build. 

When I tried to place the persistence-unit into the persistence-*.xml files nothing worked. I am sure this could be fixed in the build.xml file.
But, for me to get this working from Eclipse I had to create a persistence.xml file and place it in the META-INF directory of my project. I then included the persistence-unit shown in the xml above. Also note that I had to declare the mapped class using the class tag "com.idfbins.nexus.common.vo.busent.FBWorker
". I do not know if I have to do this for every mapped POJO or if there if I can just specify a package name and/or wildcard to define all mapped classes in my project.

These two links helped me figure this out:

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

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

More information about the jboss-user mailing list