users@glassfish.java.net

Re: CDI broken between EJB and JPA modules

From: Arun Gupta <arun.p.gupta_at_oracle.com>
Date: Wed, 07 Apr 2010 21:07:47 -0700

> Caused by: java.lang.IllegalStateException: Unable to retrieve EntityManagerFactory for unitName null
> at com.sun.enterprise.container.common.impl.EntityManagerWrapper.init(EntityManagerWrapper.java:122)
> at com.sun.enterprise.container.common.impl.EntityManagerWrapper._getDelegate(EntityManagerWrapper.java:163)
> at com.sun.enterprise.container.common.impl.EntityManagerWrapper.find(EntityManagerWrapper.java:310)
> at sample.persistence.impl.UserDaoImpl.find(UserDaoImpl.java:16)
> at sample.service.UserService.loginByGuid(UserService.java:20)
> ...
>
> If I move the @PersistenceContext into the SLSB, it works fine there. So my persistence unit seems to be configured correctly, but it doesn't seem to be visible to non-EJB classes that rely on CDI for injection.
Injection works in managed objects like Servlets, EJBs, and Managed
Beans only otherwise container has no way to inject.

>
> I've also tried @PersistenceContext(unitName="Admin") and the same thing happens (with the exception message mentioning "Admin" instead of null).
>
> Surely a simple EAR with a single EJB module using two simple injections should be easily handled by GF and Weld. These various scenarios, all resulting in one exception or another, are why I suspect GF and Weld have some module interoperability kinks to work out.
>
> I did come across your blog posts during my extensive googling into these issues, but nothing jumped out at me the first time. I will take a closer look though.
>
> In the meantime, please feel free to try either one of the EARs I've attached, and let me know if either of these simple scenarios work for you.
I did not receive any attachment, either this time or earlier.

-Arun
>
> Thanks again,
> -Dan
> [Message sent by forum member 'theodan']
>


-- 
Blog: http://blogs.sun.com/arungupta
Twitter: http://twitter.com/arungupta