8 Replies Latest reply on Dec 1, 2010 2:14 AM by Murali Kumar

    Using Renderer from MDB turned seam component in 2.1.1.CR2

    Marko Strukelj Newbie

      Hi,


      I'm upgrading my app from Seam 2.0.3.CR1 to Seam 2.1.1.CR2, and I'm having a problem using an MDB turned seam component.



      Consider a code snippet:


      @MessageDriven (activationConfig = {
      @ActivationConfigProperty (propertyName = "destinationType",
           propertyValue = "javax.jms.Queue"),
      @ActivationConfigProperty (propertyName = "destination",
           propertyValue = "queue/messagingQueue"),
      @ActivationConfigProperty (propertyName = "messageSelector",
           propertyValue = "MsgType = 'Messaging' AND MsgTransport = 'Mail'"),
      @ActivationConfigProperty (propertyName = "DLQMaxResent", propertyValue = "10")
           })
      @Name ("MailSenderMDB")
      public class MailSenderMDB implements MessageListener {
      
             @In (create = true)
             private org.jboss.seam.faces.Renderer renderer;
      
             public void onMessage(javax.jms.Message message) {
                    ...
                    ...
                    Context ctx = Contexts.getEventContext();
                    ctx.set("to", to);
                    ctx.set("message", message);
      
                    String template = getTemplate();
                    renderer.render(template);
      
                    ...
                    ...
             }
      
      }
      
      



      In the above code snippet a call to renderer.render() suddenly produces the following error:


      17:29:15,206 ERROR [JmsServerSession] Unexpected error delivering message delegator->JBossMessage[4157440]:PERSISTENT, deliveryId=0
      javax.ejb.EJBTransactionRolledbackException: Exception while processing message through MailSenderMDB:
              at org.jboss.ejb3.tx.Ejb3TxPolicy.handleInCallerTx(Ejb3TxPolicy.java:87)
              at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:130)
              at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:195)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.ejb3.mdb.MessagingContainer.localInvoke(MessagingContainer.java:249)
              at org.jboss.ejb3.mdb.inflow.MessageInflowLocalProxy.delivery(MessageInflowLocalProxy.java:268)
              at org.jboss.ejb3.mdb.inflow.MessageInflowLocalProxy.invoke(MessageInflowLocalProxy.java:138)
              at $Proxy228.onMessage(Unknown Source)
              at org.jboss.resource.adapter.jms.inflow.JmsServerSession.onMessage(JmsServerSession.java:178)
              at org.jboss.jms.client.container.ClientConsumer.callOnMessage(ClientConsumer.java:159)
              at org.jboss.jms.client.container.SessionAspect.handleRun(SessionAspect.java:802)
              at org.jboss.aop.advice.org.jboss.jms.client.container.SessionAspect14.invoke(SessionAspect14.java)
              at org.jboss.jms.client.delegate.ClientSessionDelegate$run_N8003352271541955702.invokeNext(ClientSessionDelegate$run_N8003352271541955702.java)
              at org.jboss.jms.client.container.ClosedInterceptor.invoke(ClosedInterceptor.java:170)
              at org.jboss.aop.advice.PerInstanceInterceptor.invoke(PerInstanceInterceptor.java:105)
              at org.jboss.jms.client.delegate.ClientSessionDelegate$run_N8003352271541955702.invokeNext(ClientSessionDelegate$run_N8003352271541955702.java)
              at org.jboss.jms.client.delegate.ClientSessionDelegate.run(ClientSessionDelegate.java)
              at org.jboss.jms.client.JBossSession.run(JBossSession.java:199)
              at org.jboss.resource.adapter.jms.inflow.JmsServerSession.run(JmsServerSession.java:237)
              at org.jboss.resource.work.WorkWrapper.execute(WorkWrapper.java:204)
              at org.jboss.util.threadpool.BasicTaskWrapper.run(BasicTaskWrapper.java:275)
              at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:756)
              at java.lang.Thread.run(Thread.java:619)
      Caused by: java.lang.RuntimeException: Exception while processing message through MailSenderMDB:
              at si.xxxx.messaging.MailSenderMDB.onMessage(MailSenderMDB.java:108)
              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.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.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:77)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.bpm.BusinessProcessInterceptor.aroundInvoke(BusinessProcessInterceptor.java:51)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:118)
              at org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:50)
              at sun.reflect.GeneratedMethodAccessor205.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              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.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)
              ... 23 more
      Caused by: org.jboss.seam.InstantiationException: Could not instantiate Seam component: org.jboss.seam.ui.facelet.facesContextFactory
              at org.jboss.seam.Component.newInstance(Component.java:2106)
              at org.jboss.seam.Component.getInstance(Component.java:1988)
              at org.jboss.seam.Component.getInstance(Component.java:1967)
              at org.jboss.seam.Component.getInstance(Component.java:1961)
              at org.jboss.seam.Component.getInstance(Component.java:1934)
              at org.jboss.seam.Component.getInstance(Component.java:1929)
              at org.jboss.seam.ui.facelet.RendererFacesContextFactory.instance(RendererFacesContextFactory.java:72)
              at org.jboss.seam.ui.facelet.RendererRequest.init(RendererRequest.java:45)
              at org.jboss.seam.ui.facelet.RendererRequest.run(RendererRequest.java:72)
              at org.jboss.seam.ui.facelet.FaceletsRenderer.render(FaceletsRenderer.java:43)
              at si.xxxx.messaging.MailSenderMDB.onMessage(MailSenderMDB.java:100)
              ... 52 more
      Caused by: java.lang.IllegalStateException: Application was not properly initialized at startup, could not find Factory: javax.faces.context.FacesContextFactory
              at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:267)
              at org.jboss.seam.ui.facelet.RendererFacesContextFactory.create(RendererFacesContextFactory.java:47)
              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.seam.util.Reflections.invoke(Reflections.java:22)
              at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
              at org.jboss.seam.Component.callComponentMethod(Component.java:2211)
              at org.jboss.seam.Component.callCreateMethod(Component.java:2134)
              at org.jboss.seam.Component.newInstance(Component.java:2094)
              ... 62 more
      



      Inside onMessage() method Seam stateful contexts are active.


      Application context contains:



      • org.jboss.seam.ui.facelet.facesContextFactory.component: Component(org.jboss.seam.ui.facelet.facesContextFactory)

      • org.jboss.seam.faces.facesContext.component: Component(org.jboss.seam.faces.facesContext)

      • org.jboss.seam.faces.facesContext: org.jboss.seam.faces.FacesContext@f7d90b



      Is this kind of usage deprecated? Has it never been intended to be used like this? Is there a workaround?
      Or is it a BUG >:-)


      - marko