2 Replies Latest reply on Oct 20, 2011 12:30 PM by Cody Lerum

    Exception occured when injected a mail session in stateful session bean.

    hantsy bai Master

      I tried to inject mail session in my Converstation scoped stateful session bean, and go the following exception:


      javax.faces.el.EvaluationException: javax.ejb.EJBTransactionRolledbackException: WELD-000054 Producers cannot produce non-serializable instances for injection into non-transient fields of passivating beans\\n\\nProducer\:  Producer Method [Session] with qualifiers [@Any @Default] declared as [[method] @Produces public org.jboss.seam.mail.core.MailSessionProducer.getMailSession(MailConfig)]\\nInjection Point\:  org.jboss.weld.bean.builtin.InstanceImpl$InstanceInjectionPoint@188661b
           at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102)
           at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
           at javax.faces.component.UICommand.broadcast(UICommand.java:315)
           at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:787)
           at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1252)
           at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
           at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
           at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
           at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
           at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
           at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:118)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
           at org.jboss.solder.servlet.exception.CatchExceptionFilter.doFilter(CatchExceptionFilter.java:65)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
           at org.jboss.solder.servlet.event.ServletEventBridgeFilter.doFilter(ServletEventBridgeFilter.java:72)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
           at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
           at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:139)
           at org.jboss.as.web.NamingValve.invoke(NamingValve.java:57)
           at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:49)
           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:154)
           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
           at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362)
           at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:667)
           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:952)
           at java.lang.Thread.run(Thread.java:662)
      Caused by: javax.ejb.EJBTransactionRolledbackException: WELD-000054 Producers cannot produce non-serializable instances for injection into non-transient fields of passivating beans\\n\\nProducer\:  Producer Method [Session] with qualifiers [@Any @Default] declared as [[method] @Produces public org.jboss.seam.mail.core.MailSessionProducer.getMailSession(MailConfig)]\\nInjection Point\:  org.jboss.weld.bean.builtin.InstanceImpl$InstanceInjectionPoint@188661b
           at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.handleInCallerTx(CMTTxInterceptor.java:158)
           at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:237)
           at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.required(CMTTxInterceptor.java:363)
           at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.invoke(CMTTxInterceptor.java:219)
           at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:35)
           at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
           at org.jboss.as.ejb3.component.session.SessionInvocationContextInterceptor.processInvocation(SessionInvocationContextInterceptor.java:71)
           at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
           at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
           at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:146)
           at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
           at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
           at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:76)
           at com.telopsys.siorc.forwarding.ForwardingCaseEditAction$$$view125.notifyForwarder(Unknown Source)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:597)
           at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:305)
           at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:54)
           at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:163)
           at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:299)
           at org.jboss.weld.bean.proxy.EnterpriseBeanProxyMethodHandler.invoke(EnterpriseBeanProxyMethodHandler.java:125)
           at org.jboss.weld.bean.proxy.EnterpriseTargetBeanInstance.invoke(EnterpriseTargetBeanInstance.java:62)
           at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:125)
           at com.telopsys.siorc.forwarding.ForwardingCaseEditAction$Proxy$_$$_Weld$Proxy$.notifyForwarder(ForwardingCaseEditAction$Proxy$_$$_Weld$Proxy$.java)
           at com.telopsys.siorc.forwarding.ForwardingCaseEditAction$Proxy$_$$_WeldClientProxy.notifyForwarder(ForwardingCaseEditAction$Proxy$_$$_WeldClientProxy.java)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:597)
           at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:305)
           at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:54)
           at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:163)
           at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:299)
           at org.jboss.weld.introspector.jlr.WeldMethodImpl.invokeOnInstance(WeldMethodImpl.java:188)
           at org.jboss.weld.introspector.ForwardingWeldMethod.invokeOnInstance(ForwardingWeldMethod.java:59)
           at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:198)
           at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:282)
           at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:265)
           at org.jboss.weld.event.TransactionalObserverMethodImpl.notify(TransactionalObserverMethodImpl.java:66)
           at org.jboss.weld.manager.BeanManagerImpl.notifyObservers(BeanManagerImpl.java:635)
           at org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:628)
           at org.jboss.weld.event.EventImpl.fire(EventImpl.java:75)
           at com.telopsys.siorc.forwarding.ForwardingCaseEditAction.sendInstruction(ForwardingCaseEditAction.java:235)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:597)
           at org.jboss.as.ee.component.ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptor.java:51)
           at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
           at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:370)
           at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:114)
           at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:122)
           at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
           at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)
           at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
           at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:45)
           at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
           at org.jboss.as.ejb3.component.stateful.StatefulSessionSynchronizationInterceptor.processInvocation(StatefulSessionSynchronizationInterceptor.java:132)
           at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
           at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:44)
           at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
           at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45)
           at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
           at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21)
           at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
           at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
           at org.jboss.as.ee.component.ViewDescription$ComponentDispatcherInterceptor.processInvocation(ViewDescription.java:202)
           at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
           at org.jboss.as.jpa.interceptor.SFSBInvocationInterceptor.processInvocation(SFSBInvocationInterceptor.java:58)
           at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
           at org.jboss.as.ejb3.component.stateful.StatefulComponentInstanceInterceptor.processInvocation(StatefulComponentInstanceInterceptor.java:61)
           at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
           at org.jboss.as.ejb3.component.session.SessionInvocationContextInterceptor$CustomSessionInvocationContext.proceed(SessionInvocationContextInterceptor.java:126)
           at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:233)
           at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.required(CMTTxInterceptor.java:363)
           at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.invoke(CMTTxInterceptor.java:219)
           at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:35)
           at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
           at org.jboss.as.ejb3.component.session.SessionInvocationContextInterceptor.processInvocation(SessionInvocationContextInterceptor.java:71)
           at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
           at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
           at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:146)
           at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
           at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
           at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:76)
           at com.telopsys.siorc.forwarding.ForwardingCaseEditAction$$$view125.sendInstruction(Unknown Source)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:597)
           at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:305)
           at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:54)
           at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:163)
           at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:299)
           at org.jboss.weld.bean.proxy.EnterpriseBeanProxyMethodHandler.invoke(EnterpriseBeanProxyMethodHandler.java:125)
           at org.jboss.weld.bean.proxy.EnterpriseTargetBeanInstance.invoke(EnterpriseTargetBeanInstance.java:62)
           at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:125)
           at com.telopsys.siorc.forwarding.ForwardingCaseEditAction$Proxy$_$$_Weld$Proxy$.sendInstruction(ForwardingCaseEditAction$Proxy$_$$_Weld$Proxy$.java)
           at com.telopsys.siorc.forwarding.ForwardingCaseEditAction$Proxy$_$$_WeldClientProxy.sendInstruction(ForwardingCaseEditAction$Proxy$_$$_WeldClientProxy.java)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:597)
           at org.apache.el.parser.AstValue.invoke(AstValue.java:196)
           at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
           at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:43)
           at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:56)
           at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:98)
           at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
           ... 35 more
      Caused by: org.jboss.weld.exceptions.IllegalProductException: WELD-000054 Producers cannot produce non-serializable instances for injection into non-transient fields of passivating beans\\n\\nProducer\:  Producer Method [Session] with qualifiers [@Any @Default] declared as [[method] @Produces public org.jboss.seam.mail.core.MailSessionProducer.getMailSession(MailConfig)]\\nInjection Point\:  org.jboss.weld.bean.builtin.InstanceImpl$InstanceInjectionPoint@188661b
           at org.jboss.weld.bean.AbstractProducerBean.checkReturnValue(AbstractProducerBean.java:275)
           at org.jboss.weld.bean.AbstractProducerBean.create(AbstractProducerBean.java:362)
           at org.jboss.weld.context.unbound.DependentContextImpl.get(DependentContextImpl.java:67)
           at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:693)
           at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:731)
           at org.jboss.weld.bean.builtin.InstanceImpl.get(InstanceImpl.java:115)
           at com.telopsys.siorc.forwarding.ForwardingCaseEditAction.notifyForwarder(ForwardingCaseEditAction.java:209)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:597)
           at org.jboss.as.ee.component.ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptor.java:51)
           at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
           at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:370)
           at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:114)
           at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:122)
           at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
           at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)
           at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
           at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:45)
           at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
           at org.jboss.as.ejb3.component.stateful.StatefulSessionSynchronizationInterceptor.processInvocation(StatefulSessionSynchronizationInterceptor.java:132)
           at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
           at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:44)
           at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
           at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45)
           at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
           at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21)
           at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
           at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
           at org.jboss.as.ee.component.ViewDescription$ComponentDispatcherInterceptor.processInvocation(ViewDescription.java:202)
           at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
           at org.jboss.as.jpa.interceptor.SFSBInvocationInterceptor.processInvocation(SFSBInvocationInterceptor.java:58)
           at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
           at org.jboss.as.ejb3.component.stateful.StatefulComponentInstanceInterceptor.processInvocation(StatefulComponentInstanceInterceptor.java:61)
           at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
           at org.jboss.as.ejb3.component.session.SessionInvocationContextInterceptor$CustomSessionInvocationContext.proceed(SessionInvocationContextInterceptor.java:126)
           at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:233)
           ... 144 more
      



      The related codes:



           @Inject
           private Instance<MailMessage> mailMessage;
      
           @Inject
           private Instance<CDIVelocityContext> velocityContext;
      
           @Inject
           private ResourceProvider resourceProvider;
      
           @Inject
           private Instance<Session> session;
      
      

        • 1. Re: Exception occured when injected a mail session in stateful session bean.
          hantsy bai Master
          
          @Stateful
          @ConversationScoped
          @Named("forwardingCaseEdit")
          public class ForwardingCaseEditAction {
          
          //inejct objects
          @Inject
               private Instance<MailMessage> mailMessage;
          
               @Inject
               private Instance<CDIVelocityContext> velocityContext;
          
               @Inject
               private ResourceProvider resourceProvider;
          
               @Inject
               private Instance<Session> session;
          
          
          
          // send code fragments
          
          mailMessage
                              .get()
                              .to(_to)
                              .subject(
                                        "Instrcution -- "
                                                  + this.getCurrentForwardingCase()
                                                            .getForwardingCaseSubject())
                              .bodyText(
                                        new VelocityTemplate(
                                                  resourceProvider
                                                            .loadResourceStream("/mails/fowarding_forwarder.text.vm"),
                                                  velocityContext.get())).put(values)
                              .send(session.get());