users@glassfish.java.net

Null _at_PersistenceContext: no errors, no warnings?

From: <glassfish_at_javadesktop.org>
Date: Tue, 20 Jul 2010 11:47:15 PDT

Looking for a checklist on what to do when a @PersistenceContext in a stateless session bean is null with no errors or warnings in the log.

My application is structured like this:

ear root:
* person manager EJB module
* lib:
** person manager interface jar
** configuration jar:
*** META-INF/persistence.xml

The EJB is a stateless session bean. It implements an interface contained in a jar in the lib directory.

The EJB has a field declared like this:
[code]
@PersistenceContext
private EntityManager em;
[/code]

The ear has, in its lib directory, a jar file that houses the application-wide META-INF/persistence.xml file.

Upon deploying the ear file, the session bean deploys fine. I see lots of happy deployment-like messages involving JNDI and whatnot.

When my EJB is actually invoked, it creates fine. However, its em field is null. There are no errors or warnings in the log.

I've overcome complex Weld errors, complex resource adapter errors, and am now down to this last piece.

I recall a message from Sahoo a million years ago about how you somehow needed to tell Glassfish to forcibly initialize the persistence unit, but I surely thought this was not an issue for simple stateless session beans.

Is there a list of things I should check as I try to debug this opaque error?

Thanks,
Laird
[Message sent by forum member 'ljnelson']

http://forums.java.net/jive/thread.jspa?messageID=478121