Hi,
I'm trying to deploy an application with many EJB/WAR modules.
One of them defines the persistence entities, as well as the persistence.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="entityManagerFactory" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:jboss/datasources/OracleDS</jta-data-source>
<properties>
<property name="jboss.as.jpa.providerModule" value="org.hibernate3"/>
...
...
...
</properties>
</persistence-unit>
Then, in other modules, I've got to refer the entityManagerFactory. But,it gives me the following error:
Can't find a deployment unit named entityManagerFactory at subdeployment "EJB_Module.jar" of deployment "EAR_Project.ear"
I've tryied to replace
@PersistenceContext(unitName="entityManagerFactory")
by
@PersistenceContext(unitName="EJB_DBModule.jar#entityManagerFactory")
or
@PersistenceContext(unitName="../EJB_DBModule.jar#entityManagerFactory")
But, I still get the same error.
I've tried the workaround mentionned here : http://community.jboss.org/thread/2111 and created in each module a persistence.xml file which refers the entities jar file :
<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="entityManagerFactory">
<jar-file>EJB_DBModule.jar</jar-file>
</persistence-unit>
</persistence>
But, it actually doesn't seem to load configuration from the jar file and so doesn't connect me to the database:
org.hibernate.HibernateException: 'hibernate.dialect' must be set when no Connection available
How can I share my entity manager between all the modules ? Should I duplicate all the configuration from persistence.xml in every module ?
Thank you very much