[weld-issues] [JBoss JIRA] Commented: (WELD-535) Injection does not occur into a scoped (proxied) bean the observer method is final

Dan Allen (JIRA) jira-events at lists.jboss.org
Wed May 26 17:40:55 EDT 2010

    [ https://jira.jboss.org/browse/WELD-535?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12532632#action_12532632 ] 

Dan Allen commented on WELD-535:

Classes and Aquillian test case to test observer.

public class SampleBean {

public class SampleHelper implements Serializable {

public class SampleTest {
   public static JavaArchive createTestArchive() {
      return ShrinkWrap.create("test.jar", JavaArchive.class)
            .addClasses(SampleBean.class, SampleObserver.class, SampleHelper.class);

   @Inject Event<SampleBean> sampleBeanEventSrc;

   @Inject BeanManager beanManager;

   public void testObserver() {
      sampleBeanEventSrc.fire(new SampleBean());
      beanManager.fireEvent(new SampleBean());

> Injection does not occur into a scoped (proxied) bean the observer method is final
> ----------------------------------------------------------------------------------
>                 Key: WELD-535
>                 URL: https://jira.jboss.org/browse/WELD-535
>             Project: Weld
>          Issue Type: Bug
>          Components: Events
>    Affects Versions: 1.0.1.Final
>            Reporter: Dan Allen
>             Fix For: 1.0.2.CR1
> If the observer method of a bean is private, and the bean which contains it has a scope (it's proxied), then injection into the bean does not occur.
> For example, the injection points are null when the following observer is invoked:
> @SessionScoped
> public class SampleObserver implements Serializable {
>    @Inject SampleHelper helper;
>    private void observes(@Observes final SampleBean bean) {
>       System.out.println("Did injection occur? " + (helper = null ? "no" : "yes"));
>    }
> }
> Prints:
> Did injection occur? no

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/secure/Administrators.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the weld-issues mailing list