Persistence unit dependency failure on deploy
mtuckah Aug 10, 2006 3:59 PMHello,
I have an ejb3 application packaged in the following way:
myapp.ear |---application.xml |---myentities.jar |---META-INF/persistence.xml |---(entity beans) |---mysessions.jar |---MySessionBean.java
My persistence.xml looks like this:
<persistence> <persistence-unit name="myUnit"> <jta-data-source>java:/MyDS</jta-data-source> <properties> <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/> <property name="hibernate.hbm2ddl.auto" value="validate"/> <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/> <property name="hibernate.transaction.flush_before_completion" value="true"/> <property name="hibernate.show_sql" value="false"/> <property name="jboss.entity.manager.factory.jndi.name" value="java:/MyFactory"/> <property name="jboss.entity.manager.jndi.name" value="java:/EntityManager/myUnit"/> </properties> </persistence-unit> </persistence>
Mu application.xml looks like this:
<application> <display-name>My App</display-name> <module> <ejb>myentities.jar</ejb> </module> <module> <ejb>mysessions.jar</ejb> </module> </application>
In MySession, I'm attempting to inject an EntityManager like so:
@PersistenceContext(unitName = "myUnit") private EntityManager em;
For session beans that exist within the same JAR that contains the persistence.xml, this injection works fine. However for session beans within mysessions.jar, I get the following exception on deploy:
--- MBeans waiting for other MBeans ---
ObjectName: jboss.j2ee:ear=myapp.ear,jar=mysessions.jar,name=MySessionBean,service=EJB3
State: NOTYETINSTALLED
I Depend On:
persistence.units:unitName=myUnit
--- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
ObjectName: persistence.units:unitName=myUnit
State: NOTYETINSTALLED
Depends On Me:
jboss.j2ee:ear=myapp.ear,jar=mysessions.jar,name=MySessionBean,service=EJB3
I've seen posts with similar problems but no clear cut solutions. Is my packaging correct? Should JARs within the same EAR be able to reference persistence units in other JARs? Any help would be greatly appreciated.