3 Replies Latest reply on Dec 6, 2005 5:34 AM by Doi Buon

    Task - variable error

    Doi Buon Newbie

      This is my code:

      <?xml version="1.0" encoding="UTF-8"?>
      
      <process-definition
       name="Test1">
       <swimlane name="st">
       <assignment expression="user(Every One)" />
       </swimlane>
       <swimlane name="th">
       <assignment expression="user(SH)" />
       </swimlane>
       <start-state name="start">
       <task swimlane="st">
       <controller>
       <variable name="stv"/>
       </controller>
       </task>
       <transition name="tr1" to="task1"></transition>
       </start-state>
       <end-state name="end1"></end-state>
       <task-node name="task1">
       <task swimlane="th">
       <event type="task-assign">
       <script>
       <variable name="temp1"/>
       <expression>
       temp1=executionContext.getContextInstance().getVariable("stv");
       System.out.println("=== aaaaa =====" + temp1);
       </expression>
       </script>
       </event>
       </task>
       <transition name="tr1" to="end1"></transition>
       </task-node>
      </process-definition>

      After deploy this par to server successful.
      I login with "Every One", at "Start New Process Execution" i click "start" and then put value=4 for "stv" field and then "Save and Close"
      After above step.
      I login with "SH", at "Tasklist" i click "task1" to continue process but have this error:
      15:38:19,109 DEBUG [PersistenceContext] beginning transaction
      15:38:19,125 DEBUG [PersistenceContext] rolling back transaction
      15:38:19,125 ERROR [[FacesServlet]] Servlet.service() for servlet FacesServlet threw exception
      javax.faces.FacesException: Error calling action method of component with id _id1_0:_id4
      at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:74)
      at javax.faces.component.UICommand.broadcast(UICommand.java:106)
      at javax.faces.component.UIData.broadcast(UIData.java:338)
      at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:90)
      at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:164)
      at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:271)
      at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:94)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.jbpm.webapp.filter.AuthenticationFilter.doFilter(AuthenticationFilter.java:25)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.jbpm.webapp.filter.PersistenceFilter.doFilter(PersistenceFilter.java:28)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.jbpm.webapp.filter.ContextFilter.doFilter(ContextFilter.java:19)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.jbpm.webapp.filter.LogFilter.doFilter(LogFilter.java:38)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
      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.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
      at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      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:856)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
      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:595)
      Caused by: javax.faces.el.EvaluationException: Exception while invoking expression #{homeBean.selectTaskInstance}
      at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:153)
      at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63)
      ... 38 more
      Caused by: java.lang.NullPointerException
      at org.jbpm.webapp.bean.TaskBean.initialize(TaskBean.java:98)
      at org.jbpm.webapp.bean.HomeBean.selectTaskInstance(HomeBean.java:66)
      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.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:129)
      ... 39 more

      Please help me correct it.
      Thanks

        • 1. Re: Task - variable error
          Doi Buon Newbie

          I've corrected it.
          I will be:

          <?xml version="1.0" encoding="UTF-8"?>
          
          <process-definition
           name="Test1">
           <swimlane name="st">
           <assignment expression="user(Every One)" />
           </swimlane>
           <swimlane name="th">
           <assignment expression="user(SH)" />
           </swimlane>
           <start-state name="start">
           <task swimlane="st">
           <controller>
           <variable name="stv"/>
           </controller>
           </task>
           <transition name="tr1" to="task1"></transition>
           </start-state>
           <end-state name="end1"></end-state>
           <task-node name="task1">
           <task swimlane="th">
           <event type="task-assign">
           <script>
           <variable name='temp1'/>
           <expression>
           temp1=executionContext.getContextInstance().getVariable("stv");
           System.out.println("=== aaaaa =====" + temp1);
           taskInstance.setVariable("temp1", temp1);
           ArrayList list=new ArrayList();
           list.add("Line 1");
           list.add("Line 2");
          
           taskInstance.setVariable("list", list);
          
           System.out.println("here ===============");
           ListData test1=new ListData();
           test1.setName("thtnnsjds");
           taskInstance.setVariable("test1", test1);
           </expression>
           </script>
           </event>
           <controller>
           <variable name="temp1"></variable>
           </controller>
           </task>
           <transition name="tr1" to="end1"></transition>
           </task-node>
          </process-definition>

          With this code i can access "temp1" from WEBAPP and any where in par project.

          But new problem occur, please help me.
          From line
          System.out.println("here ==============");

          I have create a variable with new object ListData.
          code here :
          package a.workflow;
          
          public class ListData{
           private String name;
          
           public ListData(){}
          
           public ListData(String name){
           System.out.println("=========="+name+"======");
           this.name=name;
           }
          
           public void setName(String name){
           this.name=name;
           }
          
           public String getName(){
           return this.name;
           }
          
           public String toString(){
           return name;
           }
          }

          I see in "userguide\configuration.html" - jBPM3.1a1 doc and config the "jbpm.cfg.xml" for new object.
          code here:
          <jbpm-configuration>
          
           <!--
           JBoss jBPM has a lot of configurable and customizable components. This configuration
           will help you to configure and deploy jBPM in your environment. We identified 3 common
           deployment environments: POJO without persistence, POJO with persistence and enterprise.
           -->
          
           <!--
           Environment 1: POJO without persistence
           =======================================
           Mainly used in testing and experimenting. This doesn't require and opening and closing
           and combining of resources. No context is needed, so there is no configuration in this
           file for that environment.
           -->
          
           <!--
           Environment 2: POJO with persistence
           ====================================
           This is the most common deployment environment for jBPM. You'll find a 'client' context
           builder, a message- and scheduler session factory configured in this environment.
           -->
           <context-builder name="client">
           <bean
           class="org.jbpm.tc.hibernate.HibernateSessionFactoryInterceptor"
           singleton="true" />
           <bean class="org.jbpm.tc.hibernate.HibernateSessionInterceptor"
           singleton="true" />
           <bean class="org.jbpm.tc.db.JbpmSessionInterceptor"
           singleton="true" />
           <bean class="org.jbpm.tc.msg.MessageServiceInterceptor"
           singleton="true" />
           <bean class="org.jbpm.tc.scheduler.SchedulerServiceInterceptor"
           singleton="true" />
           <bean
           class="org.jbpm.tc.hibernate.HibernateTransactionInterceptor"
           singleton="true" />
           <bean
           class="a.workflow.ListData"
           singleton="true" />
           </context-builder>
          
           <!-- the session factories -->
           <bean name="jbpm.hibernate.session.factory"
           class="org.hibernate.SessionFactory" singleton="true">
           <constructor
           factory-class='org.jbpm.db.hibernate.HibernateHelper'
           method='createSessionFactory' />
           </bean>
          
           <bean name="jbpm.message.service.factory"
           class="org.jbpm.msg.db.DbMessageServiceFactoryImpl" singleton="true" />
          
           <bean name="jbpm.scheduler.service.factory"
           class="org.jbpm.scheduler.db.DbSchedulerServiceFactoryImpl"
           singleton="true" />
          
           <bean name="jbpm.task.instance.factory"
           class="org.jbpm.taskmgmt.impl.DefaultTaskInstanceFactoryImpl"
           singleton="true" />
          
           <bean name="jbpm.authenticator"
           class="org.jbpm.security.authenticator.JbpmDefaultAuthenticator"
           singleton="true" />
          
           <ref name="command-executor" bean="client" />
           <ref name="timer-executor" bean="client" />
          
           <!--
           <bean name="jbpm.authorizer"
           class="org.jbpm.security.authorizer.JbpmIdentityAuthorizer"
           singleton="true" />
           -->
          
          
           <!--
           Environment 3: Enterprise
           =========================
           Use these configurations as the basis when you're deploying jBPM in an enterprise environment
          
           <context-builder name="client">
           <bean singleton="true" class="org.jbpm.tc.hibernate.HibernateSessionFactoryInterceptor">
           <field name="jndiName"><string>java:/HibernateSessionFactory</string></field>
           </bean>
           <bean singleton="true" class="org.jbpm.tc.jdbc.DataSourceConnectionInterceptor">
           <field name="dataSourceJndiName"><string>java:/DefaultDS</string></field>
           </bean>
           <bean singleton="true" class="org.jbpm.tc.hibernate.HibernateSessionInterceptor" />
           <bean singleton="true" class="org.jbpm.tc.db.JbpmSessionInterceptor" />
           <bean singleton="true" class="org.jbpm.tc.msg.MessageSessionInterceptor">
           <field name="messageSessionFactory"><ref bean="jbpm.message.session.factory" /></field>
           </bean>
           </context-builder>
           <bean name="jbpm.message.session.factory" class="org.jbpm.msg.jms.JmsMessageSessionFactoryImpl" singleton="true" />
           <bean name="jbpm.scheduler.session.factory" class="org.jbpm.scheduler.db.DbSchedulerSessionFactoryImpl" singleton="true" />
           -->
          
          
           <!--
           Miscelanious options
           ====================
           -->
           <long name="jbpm.msg.wait.timout" singleton="true">10000</long>
           <context-builder name="save-process-instance" singleton="true">
           <bean class="org.jbpm.db.save.PrepareVariablesInterceptor" />
           <bean class="org.jbpm.db.save.SaveLogsInterceptor" />
           <bean class="org.jbpm.db.save.UpdateTimersInterceptor" />
           <bean class="org.jbpm.db.save.SendMessagesInterceptor" />
           </context-builder>
          
          
          </jbpm-configuration>


          When i "Save and Close"->this action will call "task-assign" event , i have an error. So i think i am wrong in config at "jbpm.cfg.xml" file, please give me a correct file with new Class/Object.
          Thank very much.


          • 2. Re: Task - variable error
            Doi Buon Newbie

            Have any body help me?

            • 3. Re: Task - variable error
              Doi Buon Newbie

              Sorry about this question.
              I am wrong in jBPM version.
              Object Factory in jBPM 3.1.alphal1 only, but I use jBPM 3.0.2 core.
              (:D)