1 Reply Latest reply on Aug 29, 2007 11:25 AM by camunda

    ActionHandler and ClassCastException

    aledbf

      Hi, I'm a new user en jbpm and I have one problem executing an Action.
      Here is the error

      DEBUG - JbpmContextInfo - creating jbpm context with service factories '[tx, message, scheduler, logging, persistence, authentication]'
      DEBUG - JbpmContext - creating org.jbpm.JbpmContext@6018e0
      DEBUG - bPersistenceServiceFactory - creating persistence service
      DEBUG - DbPersistenceService - creating hibernate session
      DEBUG - DbPersistenceService - beginning hibernate transaction
      DEBUG - DbPersistenceService - begun hibernate transaction org.hibernate.transaction.JTATransaction@6431f
      DEBUG - GraphElement - event 'before-signal' on 'StartState(Solicitar Vacaciones)' for 'Token(/)'
      DEBUG - GraphElement - event 'node-leave' on 'StartState(Solicitar Vacaciones)' for 'Token(/)'
      DEBUG - GraphElement - event 'transition' on 'Transition(ObtenerDias)' for 'Token(/)'
      DEBUG - GraphElement - event 'node-enter' on 'Node(Determinar Dias Disponibles)' for 'Token(/)'
      DEBUG - GraphElement - executing action 'action[DeterminarDias]'
      DEBUG - Token - token[2] is locked by token[2]
      DEBUG - Token - token[2] is unlocked by token[2]
      ERROR - GraphElement - action threw exception: jbpm.SpringInvocationHandler
      java.lang.ClassCastException: jbpm.SpringInvocationHandler
       at org.jbpm.graph.def.Action.execute(Action.java:121)
       at org.jbpm.graph.def.GraphElement.executeAction(GraphElement.java:255)
       at org.jbpm.graph.def.GraphElement.executeActions(GraphElement.java:220)
       at org.jbpm.graph.def.GraphElement.fireAndPropagateEvent(GraphElement.java:190)
       at org.jbpm.graph.def.GraphElement.fireEvent(GraphElement.java:174)
       at org.jbpm.graph.def.Node.enter(Node.java:302)
       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:585)
       at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:157)
       at org.jbpm.graph.def.Node$$EnhancerByCGLIB$$a160d766.enter(<generated>)
       at org.jbpm.graph.def.Transition.take(Transition.java:151)
       at org.jbpm.graph.def.Node.leave(Node.java:393)
       at org.jbpm.graph.node.StartState.leave(StartState.java:70)
       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:585)
       at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:157)
       at org.jbpm.graph.def.Node$$EnhancerByCGLIB$$a160d766.leave(<generated>)
       at org.jbpm.graph.exe.Token.signal(Token.java:194)
       at org.jbpm.graph.exe.Token.signal(Token.java:157)
       at org.jbpm.jsf.core.action.SignalActionListener.handleAction(SignalActionListener.java:56)
       at org.jbpm.jsf.core.impl.JbpmActionListenerWrapper.processAction(JbpmActionListenerWrapper.java:82)
       at javax.faces.event.ActionEvent.processListener(ActionEvent.java:77)
       at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:758)
       at javax.faces.component.UICommand.broadcast(UICommand.java:368)
       at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:448)
       at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:752)
       at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
       at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:248)
       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:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
       at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:524)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
       at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
       at java.lang.Thread.run(Thread.java:613)
      DEBUG - JbpmContext - closing JbpmContext
      DEBUG - Services - executing default save operations
      DEBUG - HibernateSaveOperation - saving process instance
      DEBUG - SaveLogsOperation - flushing logs to logging service.
      DEBUG - CascadeSaveOperation - cascading save of 'org.jbpm.graph.exe.ProcessInstance@59fe79'
      DEBUG - Services - closing service 'persistence': org.jbpm.persistence.db.DbPersistenceService@9e160a
      DEBUG - DbPersistenceService - rolling back hibernate transaction
      DEBUG - DbPersistenceService - closing hibernate session
      


      and this is the code of the handler:
      
      
      
      public class SpringInvocationHandler implements ActionHandler
      {
      
       private String oResultVariable;
      
       private String sWSServiceUrl;
      
       private String sBeanName;
      
       private String sExtraParam;
      
       /**
       * @see org.jbpm.graph.def.ActionHandler#execute(org.jbpm.graph.exe.ExecutionContext)
       */
       public void execute( final ExecutionContext executionContext )
       {
       try
       {
       final Map<Object, Object> oProcessParams =
       (Map) executionContext.getProcessInstance().getContextInstance().getVariables();
      
       if (sExtraParam != null)
       {
       String[] aMapContent = sExtraParam.split( "=" );
       if (aMapContent != null && aMapContent.length == 2)
       {
       oProcessParams.put( aMapContent[0], aMapContent[1] );
       }
       }
      
       final String sInstanceId =
       String.valueOf( executionContext.getToken().getId() );
       final String sProcessName =
       executionContext.getToken().getNode().getName();
       final Service serviceModel =
       new ObjectServiceFactory().create( IWSFrontController.class );
       final XFire xfire = XFireFactory.newInstance().getXFire();
       final XFireProxyFactory factory = new XFireProxyFactory( xfire );
      
       try
       {
       final IWSFrontController oSpringClient =
       (IWSFrontController) factory.create( serviceModel, sWSServiceUrl );
       final Object oResult =
       oSpringClient.execute( sBeanName, sInstanceId, sProcessName, oProcessParams );
       executionContext.setVariable( oResultVariable, oResult );
       } catch (Exception e)
       {
       e.printStackTrace();
       }
       } catch (Exception e)
       {
       e.printStackTrace();
       }
       }
      ...
      
      (plus the getter and setter of the fields).
      


      I try the config-type field and bean whith the same result.
      If I see the source code of Action (line 151) the error belong a manual cast and later execution of the handler. But if I try this:
       String sConf =
       "<oResultVariable xmlns=\"urn:jbpm.org:jpdl-3.2\">result</oResultVariable><sBeanName xmlns=\"urn:jbpm.org:jpdl-3.2\">remaingTimesvc</sBeanName><sWSServiceUrl xmlns=\"urn:jbpm.org:jpdl-3.2\">http://10.0.0.126:8080/services/WSFrontController</sWSServiceUrl>";
       Object o =
       new FieldInstantiator().instantiate( jbpm.SpringInvocationHandler.class, sConf );
       ActionHandler o1 = (ActionHandler) o;
      

      works fine.

      The jbpm version is 3.2.1.

      Any idea?
      Thanks in advice.