Our project has multiple EJB modules and we want to share a single persistence.xml
file between them.
We put the persistence.xml
file inside EARs META-INF directory, but the persistence unit is not available at runtime. It seems like the file is never read since we forced incorrect classes and jar files, but nothing happens.
Why is WebLogic not reading the persistence.xml
file inside the EAR?
We get the following error when running the code, no PU is found (Available persistence units: []).
Caused By: java.lang.IllegalArgumentException: No persistence unit named 'em' is available in scope ejb1-module.jar. Available persistence units: []
persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="system-unit" transaction-type="JTA">
<jta-data-source>sysmtem-ds</jta-data-source>
<jar-file>../ejb1-module.jar</jar-file>
<class>...</class>
<class>...</class>
<class>...</class>
</persistence-unit>
</persistence>
Structure (persistence unit is placed inside the EAR)
EAR +
|- META-INF +
| - persistence.xml
|- ejb1-module.jar
|- ejb2-module.jar
|- ejb3-module.jar
We are using WebLogic 10.3.6 which uses JPA 1.0 and TopLink/EclipseLink that shipts with it.