users@glassfish.java.net

Interplay between _at_ManagedBean and CDI?

From: Laird Nelson <ljnelson_at_gmail.com>
Date: Fri, 8 Jun 2012 16:38:38 -0400

Oh, CDI and GlassFish: how I have not missed you. :-)

Dredging up an old issue.

Way back in the day we had to use @ManagedBean on our JAX-RS resource
classes because CDI injection wasn't working in GlassFish. Specifically,
following instructions, we annotated our JAX-RS resource classes with
@ManagedBean, and then used @EJB within those resource classes to get
references to various EJBs containing business logic.

Now I am at a point where I want to try CDI injection again. I took baby
steps this time.

The first step I took was to place beans.xml files in all of our JAX-RS
projects' META-INF directories, thus making them all bean archives. I took
no other action.

I am now observing that @EJB dependency injection is no longer occurring
(the previously correctly injected @EJB-annotated field in a given JAX-RS
resource class is now null).

(It may be that perhaps @ManagedBean objects and CDI just cannot coexist,
and so perhaps I am violating some specification by simply bringing a
beans.xml into the picture.)

Is this a known issue? I would have expected that nothing would have
changed except that Weld would be activated, some extra scanning would
occur, and that would be about it.

Thanks,
Laird

-- 
http://about.me/lairdnelson