I'm trying to get my container (Glassfish) to inject my persistence unit
into a faces-managed bean, but I'm not having much luck. It is my
understanding that this should be possible, but I don't see it
happening. Here's my persistence.xml:
<persistence xmlns="
http://java.sun.com/xml/ns/persistence"
version="1.0">
<persistence-unit name="em">
<jta-data-source>jdbc/Chronos</jta-data-source>
</persistence-unit>
</persistence>
I package that with the annotated entity classes in a jar in the root of
my .ear. Here's the relevant portion of my Faces-managed bean:
@PersistenceUnit
private EntityManagerFactory emf;
private EntityManager em;
And, just to be safe, I put this in my method body (as opposed a ctor,
for example):
em = emf.createEntityManager();
The instance var emf, though, is null, so I get a NullPointerException.
Am I doing something wrong? Is what I'm trying to do even possible?
I've hit a wall with it. :(
Thanks!
--
Jason Lee
Programmer/Analyst