Combining JEE6 into several modules

I want to split the parts of my WAR application into different JAR components. Each JAR component contains JPA objects, EJBs, and JSF-Composite-Components.

Example: extracting user management (XHTML, EJB, JPA-Entities) in your own bank.

At first, everything looks fine until I need to use entityManager.

Problem: In EJB JAR files, entityManager will never be entered.

I am using @PersistenceContext annotation for injection.

I have beans.xml in all META-INF folders, and everything (except entityManager) is entered correctly. It does not matter whether the persistence.xml file is placed in all JAR files or only in the WAR file.

Does anyone have glue how can this be done?

Where do I need to place different configuration files (beans.xml, persistence.xml)?

Do I need an ejb-jar.xml file?

Is this even possible?

Technology-Stack: JBoss 6.1 / PrimeFaces 3.2 / Maven / EJB 3.1 / Hibernate / JTA / CDI

+4
source share
1 answer

You need a persistence.xml file in each jar containing objects. Each such xml persistence should define a different constant.

If you want one persistence block to refer to entities defined in another save module, you need to include it as a jar file entry in the definition of a duration unit (see the example below). This works for us for a very similar package JBoss 5.1 (and then 7) / EJB3 / Hibernate, Maven, ...

http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd "version =" 1.0 "?>

<persistence-unit name="PersistenceUnitA"> <jar-file>JarContainingOtherPersistenceUnit</jar-file> <jta-data-source>java:/jboss-mysql-ds</jta-data-source> <properties> <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/> </properties> </persistence-unit> 

0
source

All Articles