0 Replies Latest reply on Jan 10, 2011 9:32 AM by mausbull.stephan.pabinger.gmail.com

    Interceptor on Stateful Session Bean - Exception during postActivate

    mausbull.stephan.pabinger.gmail.com

      Hi,


      I have an interceptor on a stateful bean with the following annotations:


      @Named
      @SessionScoped
      @Stateful
      @UserSetting //My annotation
      public class MySelector implements Serializable {
      ...
      }



      The InterceptorBinding is defined as follows:



      @Target({TYPE})
      @Retention(RUNTIME)
      @InterceptorBinding
      public @interface UserSetting {
          String prefix() default "";
      }



      Now, during activation (after the bean was passivated) I get the following exception:


      Servlet.service() for servlet Faces Servlet threw exception: java.lang.ClassCastException: org.jboss.weld.context.SerializableContextualInstanceImpl cannot be cast to java.util.List
           at org.jboss.ejb3.stateful.StatefulBeanContext.extractBeanAndInterceptors(StatefulBeanContext.java:994) [:1.7.17]
           at org.jboss.ejb3.stateful.StatefulBeanContext.postActivate(StatefulBeanContext.java:564) [:1.7.17]
           at org.jboss.ejb3.cache.simple.StatefulSessionFilePersistenceManager.activateSession(StatefulSessionFilePersistenceManager.java:324) [:1.7.17]
           at org.jboss.ejb3.cache.simple.SimpleStatefulCache.get(SimpleStatefulCache.java:491) [:1.7.17]
           at org.jboss.ejb3.stateful.StatefulInstanceAssociationInterceptor.invoke(StatefulInstanceAssociationInterceptor.java:50) [:1.7.17]
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]
           at org.jboss.ejb3.core.context.SessionInvocationContextAdapter.proceed(SessionInvocationContextAdapter.java:95) [:1.7.17]
           at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:247) [:0.0.1]
           at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.required(CMTTxInterceptor.java:349) [:0.0.1]
           at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.invoke(CMTTxInterceptor.java:209) [:0.0.1]
           at org.jboss.ejb3.tx2.aop.CMTTxInterceptorWrapper.invoke(CMTTxInterceptorWrapper.java:52) [:0.0.1]
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]
           at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76) [:1.0.0.GA]
           at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102) [jboss-aop.jar:2.2.1.GA]




      I debugged it a little bit and found out that in the StatefulBeanContext class the List in the beanAndInterceptors object is casted to StatefulBeanContext but the interceptor is actually a SerializableContextualInstanceImpl object:


      contains = (List<StatefulBeanContext>) beanAndInterceptors[3];



      Am I anything missing in my code? Can't interceptors be placed on stateful session beans?


      Thanks for your help

      Stephan