users@glassfish.java.net

Re: CDI broken between EJB and JPA modules

From: Dominik Dorn <dominik.dorn_at_gmail.com>
Date: Tue, 1 Jun 2010 15:53:00 +0200

I always have to add the unitName="nameOfYourPU" to the @PersistenceContext

(

like
@PersistenceContext(unitName="nameOfYourPU")
EntityManager em;

)


annotation to get cdi dao's working.

have you tried that?


On Tue, Jun 1, 2010 at 3:51 PM, <glassfish_at_javadesktop.org> wrote:
> Hi,
> I just wanted to add our experience with this issue (quoted my entry from the bug db
> https://glassfish.dev.java.net/issues/show_bug.cgi?id=11769):
>
> "We have the same issue in our application with the same module and library
> structure (except that our EJBs are not exposed as WebService).
> Trying to create an SLSB that has the DAO injected fails at exactly the same
> location. It even fails as soon as we turn on CDI (see below).
>
> One thing we noticed:
>
> Our SLSB was in the very beginning using JPA like this:
> @PersistenceContext EnitityManager em;
> This worked fine in GF 3.0.1, build 19. At that time, we did not have the file
> META-INF/beans.xml in the EJB module.
> Then, we wanted to get the DAO classes (which have the injected EntityManager
> reference) injected via CDI and added the required META-INF/beans.xml to the EJB
> module.
> Immediately after doing this, we get the described behavior even without trying
> to inject anything via CDI. Looks like enabling CDI changes the container
> strategy to inject JPA resources (WELD?) and that is not working."
>
> I am really surprised that this has not come up before, since it represents in my opinion a typical use case for using EJB, JPA and CDI in a middletier layer. Is nobody using this?
>
> Thanks, jhasenbe
> [Message sent by forum member 'jhasenbe']
>
> http://forums.java.net/jive/thread.jspa?messageID=472264
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>



-- 
Dominik Dorn
http://dominikdorn.com
Tausche Deine Lernunterlagen auf http://www.studyguru.eu !