cancel
Showing results for 
Search instead for 
Did you mean: 

[Resolved] JUnit tests not working, but process working in Activiti-Explorer

fergomez
Champ in-the-making
Champ in-the-making
Hello,

Since some weeks ago, I had to format my computer, so everything I had installed for Activiti and all the configurations were gone. I took me time to make everything work again, but now it does. Back then I asked about a problem I was having with Activity Explorer. Summarizing, I had JUnit tests that were working when using Spring + JPA + Activiti, but Activiti-Explorer stopped working if I wanted to use the designed workflow process. Now it's exactly the opposite: it works on Activiti-Explorer, but it doesn't in a test. I've searched all these forums and most of useful links on Google, but nothing seems to work. Here you have my code, maybe you can help me.

* saleOpportunity.bpmn
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
  <process id="saleOpportunity" name="Sale Opportunity" isExecutable="true">
    <documentation>This is an example of sale opportunity process creating or selecting a customer to be in business with.</documentation>
    <subProcess id="customerCreationSubprocess" name="Customer Creation Subprocess">
      <startEvent id="customerCreationSubprocessStart" name="Customer Creation Subprocess Start"></startEvent>
      <endEvent id="customerCreationSubprocessEnd" name="Customer Creation Subprocess End"></endEvent>
      <exclusiveGateway id="exclusivegateway1" name="Exclusive Gateway"></exclusiveGateway>
      <userTask id="selectCustomerMethod" name="Select Customer Method" activiti:assignee="${sellerName}">
        <documentation>Hello,
   
In order to select a customer you have to tell us if its account is already created or we should create an account for him/her.</documentation>
        <extensionElements>
          <activiti:formProperty id="isCustomerCreated" name="Create a customer o select one?" type="enum" variable="isCustomerCreated" required="true">     
            <activiti:value id="true" name="Select a customer"></activiti:value>
            <activiti:value id="false" name="Create a customer"></activiti:value>
          </activiti:formProperty>
        </extensionElements>
      </userTask>
      <sequenceFlow id="flow3" sourceRef="selectCustomerMethod" targetRef="exclusivegateway1"></sequenceFlow>
      <userTask id="customerCreation" name="Customer Creation" activiti:assignee="${sellerName}">
        <documentation>Please, fill all the information about this customer in order to be created.</documentation>
        <extensionElements>
          <activiti:formProperty id="clientName" name="Client Name" type="string" variable="clientName" required="true"></activiti:formProperty>
        </extensionElements>
      </userTask>
      <userTask id="customerCreated" name="Customer Created" activiti:assignee="${sellerName}">
        <documentation>Client ${clientName} has been successfully created.</documentation>
      </userTask>
      <sequenceFlow id="flow4" sourceRef="exclusivegateway1" targetRef="customerCreation">
        <conditionExpression xsi:type="tFormalExpression"><![CDATA[${isCustomerCreated == 'true'}]]></conditionExpression>
      </sequenceFlow>
      <userTask id="customerSelection" name="Customer Selection" activiti:assignee="${sellerName}">
        <documentation>Type the name of the client you want to be in business with.</documentation>
        <extensionElements>
          <activiti:formProperty id="clientName" name="Client Name" type="string" variable="clientName" required="true"></activiti:formProperty>
        </extensionElements>
      </userTask>
      <sequenceFlow id="flow9" sourceRef="customerCreationSubprocessStart" targetRef="selectCustomerMethod"></sequenceFlow>
      <sequenceFlow id="flow10" sourceRef="customerCreation" targetRef="customerCreated"></sequenceFlow>
      <sequenceFlow id="flow11" sourceRef="exclusivegateway1" targetRef="customerSelection">
        <conditionExpression xsi:type="tFormalExpression"><![CDATA[${isCustomerCreated == 'false'}]]></conditionExpression>
      </sequenceFlow>
      <exclusiveGateway id="exclusivegateway2" name="Exclusive Gateway"></exclusiveGateway>
      <sequenceFlow id="flow14" sourceRef="customerCreated" targetRef="exclusivegateway2"></sequenceFlow>
      <sequenceFlow id="flow15" sourceRef="customerSelection" targetRef="exclusivegateway2"></sequenceFlow>
      <sequenceFlow id="flow16" sourceRef="exclusivegateway2" targetRef="customerCreationSubprocessEnd"></sequenceFlow>
    </subProcess>
    <startEvent id="mainStartEvent" name="Main Start" activiti:initiator="${initiator}">
      <documentation>Hello,

Please, choose the seller.</documentation>
      <extensionElements>
        <activiti:formProperty id="sellerName" name="Seller Name" type="user" variable="sellerName" required="true"></activiti:formProperty>
      </extensionElements>
    </startEvent>
    <endEvent id="mainEndEvent" name="Main End Event">
      <documentation>Thanks!</documentation>
    </endEvent>
    <sequenceFlow id="flow12" sourceRef="mainStartEvent" targetRef="customerCreationSubprocess"></sequenceFlow>
    <sequenceFlow id="flow13" sourceRef="customerCreationSubprocess" targetRef="chooseMethod"></sequenceFlow>
    <userTask id="chooseMethod" name="Choose Method">
      <documentation>Choose a method here.</documentation>
    </userTask>
    <sequenceFlow id="flow17" sourceRef="chooseMethod" targetRef="mainEndEvent"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_saleOpportunity">
    <bpmndi:BPMNPlane bpmnElement="saleOpportunity" id="BPMNPlane_saleOpportunity">
      <bpmndi:BPMNShape bpmnElement="customerCreationSubprocess" id="BPMNShape_customerCreationSubprocess">
        <omgdc:Bounds height="271.0" width="811.0" x="210.0" y="202.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="customerCreationSubprocessStart" id="BPMNShape_customerCreationSubprocessStart">
        <omgdc:Bounds height="35.0" width="35.0" x="240.0" y="323.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="customerCreationSubprocessEnd" id="BPMNShape_customerCreationSubprocessEnd">
        <omgdc:Bounds height="35.0" width="35.0" x="940.0" y="323.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="exclusivegateway1" id="BPMNShape_exclusivegateway1">
        <omgdc:Bounds height="40.0" width="40.0" x="540.0" y="320.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="selectCustomerMethod" id="BPMNShape_selectCustomerMethod">
        <omgdc:Bounds height="59.0" width="105.0" x="350.0" y="311.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="customerCreation" id="BPMNShape_customerCreation">
        <omgdc:Bounds height="55.0" width="105.0" x="590.0" y="252.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="customerCreated" id="BPMNShape_customerCreated">
        <omgdc:Bounds height="55.0" width="105.0" x="736.0" y="252.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="customerSelection" id="BPMNShape_customerSelection">
        <omgdc:Bounds height="55.0" width="105.0" x="690.0" y="362.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="exclusivegateway2" id="BPMNShape_exclusivegateway2">
        <omgdc:Bounds height="40.0" width="40.0" x="860.0" y="320.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="mainStartEvent" id="BPMNShape_mainStartEvent">
        <omgdc:Bounds height="35.0" width="35.0" x="100.0" y="320.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="mainEndEvent" id="BPMNShape_mainEndEvent">
        <omgdc:Bounds height="35.0" width="35.0" x="1230.0" y="320.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="chooseMethod" id="BPMNShape_chooseMethod">
        <omgdc:Bounds height="55.0" width="105.0" x="1080.0" y="310.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
        <omgdi:waypoint x="455.0" y="340.0"></omgdi:waypoint>
        <omgdi:waypoint x="540.0" y="340.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
        <omgdi:waypoint x="560.0" y="320.0"></omgdi:waypoint>
        <omgdi:waypoint x="560.0" y="279.0"></omgdi:waypoint>
        <omgdi:waypoint x="590.0" y="279.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow9" id="BPMNEdge_flow9">
        <omgdi:waypoint x="275.0" y="340.0"></omgdi:waypoint>
        <omgdi:waypoint x="350.0" y="340.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow10" id="BPMNEdge_flow10">
        <omgdi:waypoint x="695.0" y="279.0"></omgdi:waypoint>
        <omgdi:waypoint x="736.0" y="279.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow11" id="BPMNEdge_flow11">
        <omgdi:waypoint x="560.0" y="360.0"></omgdi:waypoint>
        <omgdi:waypoint x="560.0" y="389.0"></omgdi:waypoint>
        <omgdi:waypoint x="690.0" y="389.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow14" id="BPMNEdge_flow14">
        <omgdi:waypoint x="841.0" y="279.0"></omgdi:waypoint>
        <omgdi:waypoint x="880.0" y="279.0"></omgdi:waypoint>
        <omgdi:waypoint x="880.0" y="320.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow15" id="BPMNEdge_flow15">
        <omgdi:waypoint x="795.0" y="389.0"></omgdi:waypoint>
        <omgdi:waypoint x="880.0" y="389.0"></omgdi:waypoint>
        <omgdi:waypoint x="880.0" y="360.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow16" id="BPMNEdge_flow16">
        <omgdi:waypoint x="900.0" y="340.0"></omgdi:waypoint>
        <omgdi:waypoint x="940.0" y="340.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow12" id="BPMNEdge_flow12">
        <omgdi:waypoint x="135.0" y="337.0"></omgdi:waypoint>
        <omgdi:waypoint x="210.0" y="337.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow13" id="BPMNEdge_flow13">
        <omgdi:waypoint x="1021.0" y="337.0"></omgdi:waypoint>
        <omgdi:waypoint x="1080.0" y="337.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow17" id="BPMNEdge_flow17">
        <omgdi:waypoint x="1185.0" y="337.0"></omgdi:waypoint>
        <omgdi:waypoint x="1230.0" y="337.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>

This is my
jpa-application-context.xml
: (note that I include the user form type from activiti-explorer)

<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.springframework.org/schema/beans   
                           http://www.springframework.org/schema/beans/spring-beans.xsd
                           http://www.springframework.org/schema/context 
                           http://www.springframework.org/schema/context/spring-context-3.0.xsd
                           http://www.springframework.org/schema/tx      
                           http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

   <context:component-scan base-package="org.workflow" />

   <bean id="activitiDataSource"
      class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
      <property name="driverClass" value="org.h2.Driver" />
      <property name="url" value="jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000" />
      <property name="username" value="sa" />
      <property name="password" value="" />
   </bean>

   <bean id="persistenceUnitManager"
      class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager">
      <property name="persistenceXmlLocation">
         <value>classpath:client/jpa-persistence.xml</value>
      </property>
   </bean>

   <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
      <property name="persistenceUnitManager" ref="persistenceUnitManager" />
   </bean>

   <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
      <property name="entityManagerFactory" ref="entityManagerFactory" />
   </bean>

   <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
      <property name="databaseType" value="h2" />
      <property name="dataSource" ref="activitiDataSource" />
      <property name="transactionManager" ref="transactionManager" />
      <property name="databaseSchemaUpdate" value="true" />
      <property name="jpaEntityManagerFactory" ref="entityManagerFactory" />
      <property name="jpaHandleTransaction" value="true" />
      <property name="jpaCloseEntityManager" value="true" />

       <property name="customFormTypes">
         <list>
           <bean class="org.activiti.explorer.form.UserFormType"/>
         </list>
       </property>
      <property name="jobExecutorActivate" value="true" />
   </bean>

   <bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
      <property name="processEngineConfiguration" ref="processEngineConfiguration" />
   </bean>

   <bean id="repositoryService" factory-bean="processEngine"
      factory-method="getRepositoryService" />
   <bean id="runtimeService" factory-bean="processEngine"
      factory-method="getRuntimeService" />
   <bean id="taskService" factory-bean="processEngine"
      factory-method="getTaskService" />
   <bean id="historyService" factory-bean="processEngine"
      factory-method="getHistoryService" />
   <bean id="managementService" factory-bean="processEngine"
      factory-method="getManagementService" />
   <bean id="formService" factory-bean="processEngine"
      factory-method="getFormService" />

   <bean id="clientService" class="org.workflow.client.ClientService" />

</beans>

I still don't use the entity Client nor its service ClientService, since first I'm trying to run a basic example.

Here is my test:

package org.workflow.client;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;

import java.io.FileInputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.List;

import org.common.AbstractTest;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.activiti.engine.RuntimeService;
import org.activiti.engine.FormService;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.TaskService;
import org.activiti.engine.task.Task;
import org.activiti.engine.form.FormProperty;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"classpath:client/jpa-application-context.xml"})
@TransactionConfiguration(transactionManager="transactionManager")
public class ClientTest extends AbstractTest {
   
   @PersistenceContext
   private EntityManager entityManager;
   
   @Autowired
   private RuntimeService rs;

   @Autowired
   private TaskService ts;
   
   @Autowired
   private FormService fs;
   
   @Autowired
   private RepositoryService reps;
      
   @Test
   public void createClient() throws Exception {
      
      String processKey = "saleOpportunity";      
      String userAssignee = "kermit";
      
      String sellerVar = "sellerName";
      
      String isCustomerCreatedVar = "isCustomerCreated";
      String isCustomerCreatedValue = "false";
      
      String clientVar = "clientName";
      String clientName = "John";
      
      String filename = "/home/MY_USER/workspace/workflow/src/main/resources/diagrams/" + processKey + ".bpmn";
      
      Map<String, Object> variableMap = new HashMap<String, Object>();
      variableMap.put(sellerVar, userAssignee);
      
      reps.createDeployment().addInputStream(processKey + ".bpmn20.xml", new FileInputStream(filename)).deploy();

      
      // main start event
      rs.startProcessInstanceByKey(processKey, variableMap);   
      
      Task task = ts.createTaskQuery().singleResult();

      assertNotNull(task);
      assertNotNull(task.getAssignee());
      assertEquals(task.getAssignee(), userAssignee);
      
      ts.complete(task.getId());
      ts.setVariable(task.getId(), sellerVar, userAssignee);
      
      
      // next -> subprocess start event -> customer method      
      task = ts.createTaskQuery().singleResult();
      
      Map<String, String> formProperties = new HashMap<String,String>();
      formProperties.put(isCustomerCreatedVar, isCustomerCreatedValue);
      
      fs.submitTaskFormData(task.getId(), formProperties);
      
      task = ts.createTaskQuery().singleResult();
      
      Map<String, Object> variables = rs.getVariables(task.getExecutionId());
      
//      assertEquals(variables.get(isCustomerCreatedVar), isCustomerCreatedValue);
//      assertFalse(Boolean.valueOf((String) variables.get(isCustomerCreatedVar)));
      
      boolean isCustomerCreated = (boolean) Boolean.valueOf((String) variables.get(isCustomerCreatedVar));

      
      // gateway
      if (isCustomerCreated)
      {
         // nope
      }
      else
      {
         // yep -> Customer Creation
         formProperties.clear();
         formProperties.put(clientVar, clientName);
         
         fs.submitTaskFormData(task.getId(), formProperties);
         
         variables.clear();
         variables = rs.getVariables(task.getExecutionId());
         
         assertEquals(variables.get(clientVar), clientName);
         
         // customer created
         task = ts.createTaskQuery().singleResult();
         ts.complete(task.getId());
         
      }
      
      // choose method
      task = ts.createTaskQuery().singleResult();
      ts.complete(task.getId());
      
   }
      
}

If I run the project as a JUnit test, I get this: (you may prefer to read it on PasteBin.com, since the bbcode doesn't show properly the code)

[php]org.activiti.engine.ActivitiException: Unknown property used in expression: ${isCustomerCreated == 'true'}
   at org.activiti.engine.impl.el.JuelExpression.getValue(JuelExpression.java:53)
   at org.activiti.engine.impl.el.UelExpressionCondition.evaluate(UelExpressionCondition.java:37)
   at org.activiti.engine.impl.bpmn.behavior.ExclusiveGatewayActivityBehavior.leave(ExclusiveGatewayActivityBehavior.java:63)
   at org.activiti.engine.impl.bpmn.behavior.FlowNodeActivityBehavior.execute(FlowNodeActivityBehavior.java:36)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationActivityExecute.execute(AtomicOperationActivityExecute.java:45)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:88)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:532)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:527)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerStart.eventNotificationsCompleted(AtomicOperationTransitionNotifyListenerStart.java:52)
   at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:56)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:88)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:532)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:527)
   at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:49)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:88)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:532)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:527)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionCreateScope.execute(AtomicOperationTransitionCreateScope.java:49)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:88)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:532)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:527)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerTake.execute(AtomicOperationTransitionNotifyListenerTake.java:66)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:88)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:532)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:527)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionDestroyScope.execute(AtomicOperationTransitionDestroyScope.java:116)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:88)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:532)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:527)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerEnd.eventNotificationsCompleted(AtomicOperationTransitionNotifyListenerEnd.java:36)
   at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:56)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:88)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:532)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:527)
   at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:49)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:88)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:532)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:527)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.take(ExecutionEntity.java:367)
   at org.activiti.engine.impl.bpmn.behavior.BpmnActivityBehavior.performOutgoingBehavior(BpmnActivityBehavior.java:105)
   at org.activiti.engine.impl.bpmn.behavior.BpmnActivityBehavior.performDefaultOutgoingBehavior(BpmnActivityBehavior.java:54)
   at org.activiti.engine.impl.bpmn.behavior.FlowNodeActivityBehavior.leave(FlowNodeActivityBehavior.java:44)
   at org.activiti.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior.leave(AbstractBpmnActivityBehavior.java:47)
   at org.activiti.engine.impl.bpmn.behavior.UserTaskActivityBehavior.signal(UserTaskActivityBehavior.java:96)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.signal(ExecutionEntity.java:350)
   at org.activiti.engine.impl.persistence.entity.TaskEntity.complete(TaskEntity.java:160)
   at org.activiti.engine.impl.cmd.CompleteTaskCmd.execute(CompleteTaskCmd.java:39)
   at org.activiti.engine.impl.cmd.CompleteTaskCmd.execute(CompleteTaskCmd.java:24)
   at org.activiti.engine.impl.cmd.NeedsActiveTaskCmd.execute(NeedsActiveTaskCmd.java:61)
   at org.activiti.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:24)
   at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:57)
   at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:47)
   at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
   at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:45)
   at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:31)
   at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:40)
   at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:35)
   at org.activiti.engine.impl.TaskServiceImpl.complete(TaskServiceImpl.java:168)
   at org.workflow.client.ClientTest.createClient(ClientTest.java:83)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:606)
   at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
   at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
   at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
   at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
   at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
   at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
   at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
   at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:232)
   at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:89)
   at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
   at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
   at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
   at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
   at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
   at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
   at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
   at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
   at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
   at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:175)
   at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
   at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.activiti.engine.impl.javax.el.PropertyNotFoundException: Cannot resolve identifier 'isCustomerCreated'
   at org.activiti.engine.impl.juel.AstIdentifier.eval(AstIdentifier.java:83)
   at org.activiti.engine.impl.juel.AstBinary$SimpleOperator.eval(AstBinary.java:27)
   at org.activiti.engine.impl.juel.AstBinary.eval(AstBinary.java:106)
   at org.activiti.engine.impl.juel.AstEval.eval(AstEval.java:50)
   at org.activiti.engine.impl.juel.AstNode.getValue(AstNode.java:26)
   at org.activiti.engine.impl.juel.TreeValueExpression.getValue(TreeValueExpression.java:114)
   at org.activiti.engine.impl.delegate.ExpressionGetInvocation.invoke(ExpressionGetInvocation.java:33)
   at org.activiti.engine.impl.delegate.DelegateInvocation.proceed(DelegateInvocation.java:37)
   at org.activiti.engine.impl.delegate.DefaultDelegateInterceptor.handleInvocation(DefaultDelegateInterceptor.java:25)
   at org.activiti.engine.impl.el.JuelExpression.getValue(JuelExpression.java:48)
   … 87 more
22 Jan 2014 09:24:07,999 [main]  INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader:316 - Loading XML bean definitions from class path resource [activiti.cfg.xml]
22 Jan 2014 09:24:08,879 [main]  INFO org.activiti.engine.impl.ProcessEngineImpl:77 - ProcessEngine default created
22 Jan 2014 09:24:08,884 [main]  INFO org.activiti.engine.impl.bpmn.deployer.BpmnDeployer:75 - Processing resource saleOpportunity.bpmn20.xml
22 Jan 2014 09:24:08,946 [main] ERROR org.activiti.engine.impl.interceptor.CommandContext:140 - Error while closing command context
org.activiti.engine.ActivitiIllegalArgumentException: unknown type 'user' sellerName
   at org.activiti.engine.impl.form.FormTypes.parseFormPropertyType(FormTypes.java:55)
   at org.activiti.engine.impl.form.DefaultFormHandler.parseConfiguration(DefaultFormHandler.java:61)
   at org.activiti.engine.impl.form.DefaultStartFormHandler.parseConfiguration(DefaultStartFormHandler.java:34)
   at org.activiti.engine.impl.bpmn.parser.handler.StartEventParseHandler.createStartFormHandlers(StartEventParseHandler.java:79)
   at org.activiti.engine.impl.bpmn.parser.handler.StartEventParseHandler.executeParse(StartEventParseHandler.java:53)
   at org.activiti.engine.impl.bpmn.parser.handler.StartEventParseHandler.executeParse(StartEventParseHandler.java:35)
   at org.activiti.engine.impl.bpmn.parser.handler.AbstractBpmnParseHandler.parse(AbstractBpmnParseHandler.java:79)
   at org.activiti.engine.impl.bpmn.parser.handler.AbstractFlowNodeBpmnParseHandler.parse(AbstractFlowNodeBpmnParseHandler.java:27)
   at org.activiti.engine.impl.bpmn.parser.handler.AbstractActivityBpmnParseHandler.parse(AbstractActivityBpmnParseHandler.java:35)
   at org.activiti.engine.impl.bpmn.parser.BpmnParseHandlers.parseElement(BpmnParseHandlers.java:73)
   at org.activiti.engine.impl.bpmn.parser.BpmnParse.processFlowElements(BpmnParse.java:407)
   at org.activiti.engine.impl.bpmn.parser.handler.ProcessParseHandler.transformProcess(ProcessParseHandler.java:82)
   at org.activiti.engine.impl.bpmn.parser.handler.ProcessParseHandler.executeParse(ProcessParseHandler.java:44)
   at org.activiti.engine.impl.bpmn.parser.handler.ProcessParseHandler.executeParse(ProcessParseHandler.java:30)
   at org.activiti.engine.impl.bpmn.parser.handler.AbstractBpmnParseHandler.parse(AbstractBpmnParseHandler.java:79)
   at org.activiti.engine.impl.bpmn.parser.BpmnParseHandlers.parseElement(BpmnParseHandlers.java:73)
   at org.activiti.engine.impl.bpmn.parser.BpmnParse.transformProcessDefinitions(BpmnParse.java:367)
   at org.activiti.engine.impl.bpmn.parser.BpmnParse.execute(BpmnParse.java:190)
   at org.activiti.engine.impl.bpmn.deployer.BpmnDeployer.deploy(BpmnDeployer.java:86)
   at org.activiti.engine.impl.persistence.deploy.DeploymentManager.deploy(DeploymentManager.java:42)
   at org.activiti.engine.impl.cmd.DeployCmd.execute(DeployCmd.java:68)
   at org.activiti.engine.impl.cmd.DeployCmd.execute(DeployCmd.java:33)
   at org.activiti.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:24)
   at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:57)
   at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:31)
   at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:40)
   at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:35)
   at org.activiti.engine.impl.RepositoryServiceImpl.deploy(RepositoryServiceImpl.java:75)
   at org.activiti.engine.impl.repository.DeploymentBuilderImpl.deploy(DeploymentBuilderImpl.java:139)
   at org.activiti.designer.test.ProcessTestSaleOpportunity.startProcess(ProcessTestSaleOpportunity.java:26)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:606)
   at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
   at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
   at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
   at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
   at org.activiti.engine.test.ActivitiRule$1.evaluate(ActivitiRule.java:124)
   at org.junit.rules.RunRules.evaluate(RunRules.java:20)
   at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
   at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
   at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
   at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
   at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
   at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
   at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
   at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
   at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
   at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
   at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
[/php]

Also note that I have two different (but probably related) problems: variables seem not to be stored in the process (I even tried to add them manually by using setVariable (
ts.setVariable(task.getId(), sellerVar, userAssignee);
), so it doesn't find them afterwards in other tasks of the same process, but they don't have any problem using explorer and they were stored back then with my other configuration. Also, it's not detecting my user form type classes, but I have
activiti-explorer-5.14.jar
in my classpath (I can find both formtype and renderer in the package explorer of Eclipse).

I'm probably having a basic mistake, but I've been for too much time trying to fix this and testing things with no success and I don't know where to continue. Somebody may be in the same situation as me, or have encountered something similar, and can be easily fixable. Also, next time people can save time with similar problems if it's something very simple. Thanks a lot for your help.



Kind regards.
3 REPLIES 3

fergomez
Champ in-the-making
Champ in-the-making
Also, I did not find any unit test for a slightly complex workflow which implies the use of several different tasks, variable access and forms. Where could I find something like this? Thanks again.

jbarrez
Star Contributor
Star Contributor
It's pretty easy actually: you fetch and complete a task:

<code>
Task task = ts.createTaskQuery().singleResult();

  assertNotNull(task);
  assertNotNull(task.getAssignee());
  assertEquals(task.getAssignee(), userAssignee);

  ts.complete(task.getId());
  ts.setVariable(task.getId(), sellerVar, userAssignee);
</code>

The sequence flow goes to the exclusive gateway:

<code>
    <sequenceFlow id="flow3" sourceRef="selectCustomerMethod" targetRef="exclusivegateway1"></sequenceFlow>
</code>

The outgoing sequence flow out of the gateway use the variable:

<code>
     <sequenceFlow id="flow4" sourceRef="exclusivegateway1" targetRef="customerCreation">
        <conditionExpression xsi:type="tFormalExpression"><![CDATA[${isCustomerCreated == 'true'}]]></conditionExpression>
      </sequenceFlow>
</code>

HOWEVER, it is only LATER in the test you add the 'isCustomerCreated' variable. So the error is correct, the variable was never passed into the engine at that point.

fergomez
Champ in-the-making
Champ in-the-making
It was very easy indeed. I just did not realize about it, but it's working fine right now. Thanks a lot for your time.

PS: A "resolved" tag in each title thread would be awesome. Could you edit my first post? Thanks again.