[jboss-dev-forums] [JBoss AS7 Development] - PersistenceContext injection from a different jar
guinotphil
do-not-reply at jboss.com
Wed Aug 3 11:27:40 EDT 2011
guinotphil [http://community.jboss.org/people/guinotphil] created the discussion
"PersistenceContext injection from a different jar"
To view the discussion, visit: http://community.jboss.org/message/619188#619188
--------------------------------------------------------------
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 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
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/619188#619188]
Start a new discussion in JBoss AS7 Development at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2225]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-dev-forums/attachments/20110803/88bb9d79/attachment.html
More information about the jboss-dev-forums
mailing list