3 Replies Latest reply on Jan 10, 2012 2:02 AM by Lawrence Li

    Problem with Seam Events and jBPM

    Marshall Treadaway Newbie

      I am using Seam 2.1.0, JBoss 4.2.2, and jBPM 3.2.1.


      I have a problem that occurs whenever I raise Seam events within a business process.  It is very difficult to fully characterize the problem.  Here is what I know.  I have a business process that was working all the way through with no real logic behind.  I had stubbed out all the action methods that I was calling (from with action nodes).  When I started adding real logic, one of the first things I did was use a Home object to make a change to an entity.  Whenever, I do this, I end up getting an exception that is displayed on the Seam Debug Page.  


      Exception during request processing:
      Caused by java.lang.NullPointerException with message: "Argument Error: Parameter message is null"
      
      com.sun.faces.context.FacesContextImpl.addMessage(FacesContextImpl.java:350)
      org.jboss.seam.faces.FacesMessages.beforeRenderResponse(FacesMessages.java:46)
      org.jboss.seam.jsf.SeamPhaseListener.beforeRenderResponse(SeamPhaseListener.java:485)
      org.jboss.seam.jsf.SeamPhaseListener.beforeServletPhase(SeamPhaseListener.java:146)
      org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:116)
      com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:222)
      com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
      javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
      org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
      org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
      org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:390)
      org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:517)
      org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
      org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
      org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
      org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
      org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
      org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
      org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
      org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
      org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
      java.lang.Thread.run(Thread.java:619)
      



      This is non-descriptive really.  Through debugging, I find that an afterTransactionSuccess was raised (by my Home object...this is normal).  Somehow, the BusinessProcess component is observing this event (or intercepting it, because there are no @Observer annotations in this class).  When it does so, it attempts to resume the task which has already ended.  My action has performed its work and transitioned out of the node using one of the transitions.  During this process, the transaction is committed as expected.  This is when I get this problem.  Anyways, the message causing the issue with FacesMessages above is added by this method on BusinessProcess, which is called from BusinessProcess.resumeTask:


         protected void taskEnded(Long taskId)
         {
            StatusMessages.instance().addFromResourceBundleOrDefault(
                  StatusMessage.Severity.WARN, 
                  "org.jboss.seam.TaskEnded", 
                  "Task #0 already ended", 
                  taskId
               );
         }
      



      I can work around this in some cases by overriding the method that raises the event within the Home object, which is undesirable.  However, there are other instances when I cannot eat the event before it is raised.


      Whenever I come across the issue, everything gets persisted correctly, but I get the exception, which redirects to the Seam Debug Page.  Apparently, the process advances normally too, because I can navigate back to my inbox and the correct task is waiting for me.


      Any ideas?