@In should work for injecting your entityManager... but don't put @PersistenceContext for anything else than entityManager.
I think you have some entityManager that has no persistence unit name in its @PersistenceContext and does not know where to find it. You don't normally have to give the persistence unit name every time you inject an entityManager.
My advice would be to put your persistence.xml in your ear's jar in a META-INF directory, and make it reference your jar that contains entity beans like this:
<persistence-unit name="xxx_pu" transaction-type="JTA"> <provider>org.hibernate.ejb.HibernatePersistence (or else)</provider> <jta-data-source>anyDS</jta-data-source> <jar-file>../lib/yourjar.jar</jar-file> (...)
Hope this helps if you don't get a better answer
well, I got a step further. Inside, the entities.jar, there was on EntityManager with @PersistenceContext being used. When I changed the unitName, it then could not find the unitName(instead of null), then when I deleted it, it all worked fine. I am not sure why someone in the jar trying to get EntityManager injected into it would fail since all the entity beans and the PU is in that same file.
Now, I get to the point where it can't find the NamedQueries, so I will try your solution and see if that works.
nope, that did not seem to work :(. I have this now
webrates.ear - lib - entities.jar //still has persistence.xml file in it(should I delete it?) - commons-beanutils.jar - etc. etc.(same as booking example here) - META-INF - new persistence.xml file - application.xml - jboss-app.xml - jboss-seam.jar - webrates.jar //no entities, just EJB3 stateless or stateful beans - webrates.war
oh, I missed an exception. It is looking for the jar on the filesystem instead of in the ear so it does not work....
13:20:35,593 WARN [InputStreamZippedJarVisitor] Unable to find file (ignored): vfszip:/D:/BBROOT/jboss-5.0.0.CR2/server/default/lib/xcore3.jar java.io.IOException: Child not found xcore3.jar for FileHandler@7069248[path= co ntext=file:/D:/BBROOT/jboss-5.0.0.CR2/server/default/lib/ real=file:/D:/BBROOT/j boss-5.0.0.CR2/server/default/lib/]
interesting, so I ended up putting entities.jar on the
filesystem and not in the ear and with your change, it worked, but
now, it loads the EJB3 layer for every ear that uses it which
is not what I want either as I want them all to share that layer
and share the cache.
Is there any way to put the entities.jar in the classpath of
all my ear files so they can share this layer?