users@glassfish.java.net

@PersistenceContext ignored in library jar classes?

From: <forums_at_java.net>
Date: Tue, 28 Aug 2012 10:07:25 -0500 (CDT)

I have built a minimal .ear containing an ejb.jar on top level and a
library.jar in the lib folder of the .ear. The library.jar contains a
META-INF/persistence.xml, both ejb.jar and library.jar contain empty
META-INF/beans.xml. @Injection works fine in both jars. Within the
library.jar I try to inject an EntityManager with
@PersistenceContext(unitName="xxx") EntityManager em; I think at deploy time
this annotation is regarded by glassfish, because an incorrect unitName leads
to an appropriate deployment error. At runtime, alas, the member is allways
null. The same annotation within the ejb.jar works fine. Could this be a bug
in glassfish? I'm using 3.1.2.2 and have tried it even with 3.1.0, same
effect. thank you for your help /roland

--
[Message sent by forum member 'bergler']
View Post: http://forums.java.net/node/889633