0 Replies Latest reply on Jan 12, 2009 2:25 AM by Ninh Nguyen Duy

    SOAPRequestHander problem on client side

    Ninh Nguyen Duy Newbie

      I'm trying to implement a client that consumes conversational web services, following this example Accessing Seam WebServices from a standalone Client, i get the following exception :


      22:54:40,670 INFO  [STDOUT] handleInbound... cid = 2
      22:55:11,559 INFO  [STDOUT] JbpmClient:: after processMgmtService.getProcessDefinition
      22:55:11,560 FATAL [application] java.lang.IllegalStateException: No active event context
      javax.faces.el.EvaluationException: java.lang.IllegalStateException: No active event context
           at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:91)
           at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:91)
           at javax.faces.component.UICommand.broadcast(UICommand.java:383)
           at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:321)
           at org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:296)
           at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:253)
           at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:466)
           at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
           at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
           at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
           at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
           at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:51)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:38)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:177)
           at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:267)
           at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:380)
           at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:507)
           at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
           at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
           at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
           at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
           at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
           at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
           at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
           at java.lang.Thread.run(Unknown Source)
      ...



      in order to test my conversational web services i've modified the test javascript in seambay and it works with the test javascript, that means i have probably problem only on the client side.


      Client :


      ...
      import com.itemis.jbpmclient.ws.SOAPRequestHandler;
      
      @Name("client")
      public class JbpmClient {
           private SOAPRequestHandler soapRequestHandler = new SOAPRequestHandler();
           
           @Begin
           public void getProcessDefinition() {
                System.out.println("JbpmClient:: before processMgmtService.getProcessDefinition");
                
                JbpmService processMgmtService = new JbpmService_Service().getJbpmServicePort();
                
             
                BindingProvider bp = (BindingProvider)processMgmtService;
                ArrayList l = new ArrayList();
                   l.add(soapRequestHandler);
                   bp.getBinding().setHandlerChain(l);
            
                
                processMgmtService.getProcessDefinition();
                System.out.println("JbpmClient:: after processMgmtService.getProcessDefinition");
           }
           
           public void executeProcess() {
                System.out.println("JbpmClient:: before processMgmtService.executeProcess");
                
                JbpmService processMgmtService = new JbpmService_Service().getJbpmServicePort();
                
             
                BindingProvider bp = (BindingProvider)processMgmtService;
                ArrayList l = new ArrayList();
                          l.add(soapRequestHandler);
                         bp.getBinding().setHandlerChain(l);
             
                
                processMgmtService.executeProcess();
                System.out.println("JbpmClient:: after processMgmtService.executeProcess");
           }
      }



      Web services :


      @Stateless
      @Name("jbpmService")
      @WebService(name = "JbpmService", serviceName = "JbpmService")
      public class ProcessMgmtServiceBean implements ProcessMgmtServiceRemote {
           
           @WebMethod
           public String getProcessDefinition() {
                System.out.println("ProcessMgmtServiceBean::getProcessDefinition:: current conversation id : " + getCurrentConversation());
                
                ProcessMgmtBean processMgmt = getProcessMgmt();
                return processMgmt.uploadProcessDefinition();
           }
           
           @WebMethod
           public String executeProcess() {
                System.out.println("ProcessMgmtServiceBean::executeProcess:: current conversation id : " + getCurrentConversation());
                
                ProcessMgmtBean processMgmt = getProcessMgmt();
                return processMgmt.createProcessInstance();
           }
      
              private ProcessMgmtBean getProcessMgmt() {
                System.out.println("ProcessMgmtServiceBean::getProcessMgmt:: current conversation id : " + getCurrentConversation());
                return (ProcessMgmtBean)Component.getInstance(ProcessMgmtBean.class, true);
           }
           
           private String getCurrentConversation() {
                return Conversation.instance().getId();
           }
      }



      Conversational seam component :


      @Conversational
      @Scope(value=ScopeType.CONVERSATION)
      @Name("processMgmt")
      public class ProcessMgmtBean implements Serializable {
           
           private ProcessDefinition processDefinition;
           private ProcessInstance processInstance;
           private ContextInstance contextInstance;
      
      ...
      
              @Begin(join = true)
           public String uploadProcessDefinition() {
                //processDefinition = ProcessDefinition.parseXmlString(new String(processDefinitionFile));
                
                System.out.println("ProcessMgmtBean::uploadProcessDefinition:: current conversation : " + getCurrentConversation());
                
                processDefinition = ProcessDefinition.parseXmlString(
                     "<process-definition  name='AddressCleaner'>" +
      
                          "<start-state name='start'>" +
                               "<transition to='end'></transition>" +
                          "</start-state>" +
      
                          "<end-state name='end'></end-state>" +
      
                     "</process-definition>"
                );
                
                return "successful";          
           }
           
      
           public String createProcessInstance() {
                
                System.out.println("ProcessMgmtBean::createProcessInstance:: current conversation : " + getCurrentConversation());
                
                processInstance = new ProcessInstance(processDefinition);
      
                rootToken = processInstance.getRootToken();
                
                displayStatus(processInstance);
                
                return "successful";
      
           }
      
      ...
      
              public void displayStatus(ProcessInstance instance) {  
                String nodeName = instance.getRootToken().getNode().getName();  
                System.out.println("You are now in node: "+nodeName);  
           }
           
           private String getCurrentConversation() {
                return Conversation.instance().getId();
           }
           
           @End
           public void end() {}
      }



      Thanks in advance for any hints and suggestion !!!


      Nguyen Duy Ninh.