2 Replies Latest reply on Jul 31, 2008 1:46 PM by nimo stephan

    Using @Observer(UserIdentityStore.EVENT_USER_CREATED) twice

    nimo stephan Master

      Hello,


      I have two different SessionBeans and referenced these with
      two differend @Name-Annotations.


      In my SessionBeans I use this:


      SessionBean1:


      @Observer(UserIdentityStore.EVENT_USER_CREATED)
      public void doThis(){..}



      SessionBean2:


      @Observer(UserIdentityStore.EVENT_USER_CREATED)
      public void doThat(){..}





      I referenced my View with SessionBean2,
      but SEAM invokes the Observer comming from SessionBean1 - the result is a 'java.lang.NullpointerException'.


      When I delete the Observer from SessionBean1,
      then all works well and the Observer from SessionBean2 is called.


      How can I secure starting the Observer from SessionBean2 without deleting the Observer from SessionBean1 ??




        • 1. Re: Using @Observer(UserIdentityStore.EVENT_USER_CREATED) twice
          Markus Dahm Novice

          Well, Seam of course call all observer methods when the even occurs, the order can not predicted in general, but probably depends just on the name of the components. I.e. the order when Seam scans for components in the class path.


          What causes the NPE? You should provide a stack trace here...

          • 2. Re: Using @Observer(UserIdentityStore.EVENT_USER_CREATED) twice
            nimo stephan Master

            I do use two different names for my sessionBeans.


            I can only use this Observer one time in ALL Java-Beans..
            so I have to create one extra-class for the observer and catch all cases..am I right or is there another way?


            my stack trace:


            ...
            Caused by: java.lang.NullPointerException
                 at sessionBean.Helper.create(Helper.java:345)
                 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                 at java.lang.reflect.Method.invoke(Unknown Source)
                 at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
                 at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
                 at org.jboss.seam.intercept.EJBInvocationContext.proceed(EJBInvocationContext.java:44)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
                 at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:46)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                 at org.jboss.seam.persistence.ManagedEntityIdentityInterceptor.aroundInvoke(ManagedEntityIdentityInterceptor.java:48)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                 at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:31)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                 at org.jboss.seam.core.ConversationInterceptor.aroundInvoke(ConversationInterceptor.java:65)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                 at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                 at org.jboss.seam.persistence.EntityManagerProxyInterceptor.aroundInvoke(EntityManagerProxyInterceptor.java:26)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                 at org.jboss.seam.persistence.HibernateSessionProxyInterceptor.aroundInvoke(HibernateSessionProxyInterceptor.java:27)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                 at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
                 at org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:50)
                 at sun.reflect.GeneratedMethodAccessor12650.invoke(Unknown Source)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                 at java.lang.reflect.Method.invoke(Unknown Source)
                 at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
                 at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
                 at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                 at org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor.invoke(ExtendedPersistenceContextPropagationInterceptor.java:57)
                 at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                 at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
                 at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                 at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
                 at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                 at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126)
                 ... 167 more