users@glassfish.java.net

Re: EntityManager not being injected into abstract EJB?

From: Marina Vatkina <marina.vatkina_at_oracle.com>
Date: Wed, 14 Apr 2010 10:17:12 -0700

It might be the way how our deployment code processes stand-alone EJB
module (in a non-embedded case as well). Does it make a difference if
you package them together?

thanks,
-marina

glassfish_at_javadesktop.org wrote:
> I'm using Glassfish 3.0.1 in embedded mode.
>
> I (like millions of others) have an AbstractDAO class. It contains a @PersistenceContext annotation that is applied to an internal protected EntityManager em field.
>
> At test time, I have a ConcreteDAO that exends AbstractDAO and makes use of the injected em.
>
> However, the test fails when em.persist() is called, claiming that injection into AbstractDAO's em has failed. So the em is non-null, but the lazy initialization of its innards fails.
>
> I was wondering if there are known problems in this area. The error message, at root, is the following, and bears a suspicious resemblance to issue 7473 (fixed; see https://glassfish.dev.java.net/issues/show_bug.cgi?id=7473):
>
> [code]
> Caused by: java.lang.IllegalStateException: Unable to retrieve EntityManagerFactory for unitName null
> at com.sun.enterprise.container.common.impl.EntityManagerWrapper.init(EntityManagerWrapper.java:121)
> at com.sun.enterprise.container.common.impl.EntityManagerWrapper.doTxRequiredCheck(EntityManagerWrapper.java:141)
> at com.sun.enterprise.container.common.impl.EntityManagerWrapper.doTransactionScopedTxCheck(EntityManagerWrapper.java:134)
> at com.sun.enterprise.container.common.impl.EntityManagerWrapper.persist(EntityManagerWrapper.java:252)
> at com.jenzabar.ngp.dao.ejb.AbstractDAO.persist(AbstractDAO.java:44)
> [/code]
>
> If it matters, at test time AbstractDAO is found in its own jar file (no ejb-jar.xml) and ConcreteDAO is found on the classpath by the Glassfish embedded scanning mode triggered by EJBContainer.createEJBContainer(). Perhaps there's an issue there?
>
> Best,
> Laird
> [Message sent by forum member 'ljnelson']
>
> http://forums.java.net/jive/thread.jspa?messageID=396952
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>