I´ve a setup that look like yours, what I did to make it work was creating a project jar just to keep the persistence (like you). This jars is added to the lib dir of the EAR, but the path for the jar in mine is like this:
This KernelCMP is one of the my EJB modules. The ear structure is like this:
Thanks for the response.
Question: are you creating multiple entity managers with the same persistence unit like I am trying to do?
I will try jar-file without the ../ and see if that helps.
Yes, I have 5 modules using the same PU, that´s why I create a separate persistence.jar in the first place. I just simplified the structure for the post.
Right. Figured I would verify. Thanks.
Well I found what was making the persistence.xml in the lib directory be ignored. It was the fact I was deploying through mvn jboss-as:deploy (my ear project).
When I instead deployed by mvn clean install, then copied the EAR file created over to the deploy directory... it deployed without the "YourEntity is not mapped" error. Making me clearly see that yes, the persistence Unit was picked up.
Now I get an NPE from hibernate!!!
15:11:09,400 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/vosa-socialauth].[vosa-socialauth]] (http-localhost-127.0.0.1-8080-4) Servlet.service() for servlet vosa-socialauth threw exception: java.lang.NullPointerException
at org.hibernate.engine.transaction.internal.jta.JtaStatusHelper.getStatus(JtaStatusHelper.java:73) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.engine.transaction.internal.jta.JtaStatusHelper.isActive(JtaStatusHelper.java:115) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.engine.transaction.internal.jta.CMTTransaction.join(CMTTransaction.java:149) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.ejb.AbstractEntityManagerImpl.joinTransaction(AbstractEntityManagerImpl.java:1207) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.ejb.AbstractEntityManagerImpl.postInit(AbstractEntityManagerImpl.java:176) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.ejb.EntityManagerImpl.<init>(EntityManagerImpl.java:89) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.ejb.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:125) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.ejb.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:120) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
What the heck
OK to conclude this for anyone who happens upon this post:
My problem was not totally resolved by placing the shared persistence unit in a jar within the EAR's lib directory. This made WebApp1.war to find it, but WebApp2.war did not.
I didn't realize that WebApp2.war is actually a spring application that uses spring beans and the spring-mvc stuff. That seemed to be the only factor that made WebApp2.war different than WebApp1.war. So Crap!
I never fixed this, and ended up just moving to the SpringJdbc template stuff for the spring app writing and reading directly to and from the tables that were created automatically from the Hibernate entity being loaded from JPA enabled WebApp1.war. Easy enough for my situation. Glad I had that option.
So long story short... Spring3 + entity manager that uses a shared persistence unit = no good so far. I'll try to come up with an example appliation that reproduces the problem so i can open something up on the issue tracker. That will be the end of it.
Thanks anyone who took a look at this.