Reputation: 290
I write Entity.jar .It's EJB Module contain entity class and etitydao class. When i run it on GlassFish , i have error:
Caused by: java.lang.IllegalStateException: Unable to retrieve EntityManagerFactory for unitName null
at com.sun.enterprise.container.common.impl.EntityManagerWrapper.init(EntityManagerWrapper.java:138)
at com.sun.enterprise.container.common.impl.EntityManagerWrapper.doTxRequiredCheck(EntityManagerWrapper.java:158)
at com.sun.enterprise.container.common.impl.EntityManagerWrapper.doTransactionScopedTxCheck(EntityManagerWrapper.java:151)
at com.sun.enterprise.container.common.impl.EntityManagerWrapper.persist(EntityManagerWrapper.java:281)
at com.styl.thincapayment.dao.impl.DataAccessImpl.insertToDatabase(DataAccessImpl.java:42)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
I think it comes from persistence.xml . I put it wrong place. How to resolve this problem.
I put persistence file in entities/src/resources/persistence.xml . I use Maven to manage project
Declaration EntityManager:
@PersistenceContext(unitName="entities")
protected EntityManager entityManager;
Upvotes: 1
Views: 2531
Reputation: 90417
persistence.xml
should be put inside the folder CLASS_PATH_ROOT/META-INF
.
If you are using Maven 's standard project layout , the path should be src/main/resources/META-INF/persistence.xml
Upvotes: 1