I have project with two ejb-jars located in [WAR]/WEB-INF/lib. Both ejb-jars uses JPA and contains classes annotated @Entity
. But I have problems with packaging and deployment (Glassfish 4). If both of my jars contains persistence.xml then I get following Exception on delpoyment
java.lang.RuntimeException: Could not resolve a persistence unit corresponding to the persistence-context-ref-name [...] in the scope of the module called [...]. Please verify your application.
I've put persistence.xml
in WAR/META-INF and delete persistence.xml
from ejb-jars. Deployment is successful, but I get Exception in runtime
java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager:
Exception Description: Problem compiling [SELECT ...].
[14, 18] The abstract schema type 'MyClass' is unknown.
MyClass
is @Entity
class from one of ejb-jars. I think problem is missing persistence.xml
in this ejb-jar.
Finally I've try to put persistence.xml
in WAR and in ejb-jars, but again I get
java.lang.RuntimeException: Could not resolve a persistence unit corresponding to the persistence-context-ref-name [...] in the scope of the module called [...]. Please verify your application.
What is a proper place to put persistence.xml
and what is a proper way to package such application?