I am using JBoss 4.2.3 application server.
I have an EAR that currently contains 2 EJB (EJB 3) jars.
In the main EJB jar I have persistence.xml file with the data source configurations.
From the secondary EJB jar file I can successfully call the the EntityManager and read\write entities that are defined in the main EJB jar that contains the persistence.xml
If I try to put an entity in the secondary EJB jar module and then persist it via the EntityManager that uses the persistence unit from the main EJB I get an exception:
Caused by: org.hibernate.hql.ast.QuerySyntaxException: [ENTITY-CLASS-NAME] is not mapped
The solution I found is to create another persistence.xml in the secondary EJB module and change the persistence unit name.
I am not sure whether what I tried to do is correct? Can you please contribute whether I can have a way to share the same persistence.xml withing multiple EJB modules in the EAR (in a way I can have entities in both EJB modules)?