AnsweredAssumed Answered

Can't find scripting engine for 'groovy'

Question asked by wiwengweng on Sep 14, 2011
Latest reply on Dec 17, 2013 by jbarrez
I had a bpmn20.xml file like this:(in fact this is the demo in the book(activiti in action))


<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL
    targetNamespace="http://www.bpmnwithactiviti.org">
  <process id="bookorder" name="bookorder">
    <startEvent id="startevent1" name="Start"/>
    <scriptTask id="scripttask1"                                      
                name="Validate order"
                scriptFormat="groovy">
      <script>
        out:print "validating order for isbn " + isbn + "\n";           
      </script>
    </scriptTask>
    <sequenceFlow id="sequenceflow1" name="Validate order" 
        sourceRef="startevent1" targetRef="scripttask1"/>
    <userTask id="usertask1" name="Complete order">                   
      <documentation>book order user task</documentation>
      <potentialOwner>
        <resourceAssignmentExpression>
          <formalExpression>sales</formalExpression>                     
        </resourceAssignmentExpression>
      </potentialOwner>
    </userTask>
    <sequenceFlow id="sequenceflow2" name="Sending to management"
        sourceRef="scripttask1" targetRef="usertask1"/>
    <endEvent id="endevent1" name="End"/>
    <sequenceFlow id="sequenceflow3" name="Ending process"
        sourceRef="usertask1" targetRef="endevent1"/>
  </process>
</definitions>


then define the process engine like this and deploy it :

package com.activiti.examples.bpmn.test;

import static org.junit.Assert.*;

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

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineConfiguration;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import org.junit.Test;

public class OrderInDetailTest {
     @Test
     public void startBookOrder() throws FileNotFoundException {
      //ProcessEngine processEngine = new ProcessEngineBuilder().
         //configureFromResource("activiti.cfg.xml").buildProcessEngine();
      ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
      ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("activiti.cfg.xml");
      RuntimeService runtimeService = processEngine.getRuntimeService();
      RepositoryService repositoryService = processEngine.getRepositoryService();
      //use absolute file path to deploy
      repositoryService.createDeployment().addInputStream("bookorderdetail.bpmn20.xml", new FileInputStream(
            new File("E:/activiti-5.4/activiti-5.4/workspace/activiti-engine-examples/src/main/" +
                  "process/org/activiti/examples/bpmn/bookorder/bookorderdetail.bpmn20.xml"))).deploy();
       Map<String, Object> variableMap = new HashMap<String, Object>();
       variableMap.put("isbn", "123456");
       TaskService taskService = processEngine.getTaskService();
       ProcessInstance processInstance =                                   
           runtimeService.startProcessInstanceByKey(                       
               "bookorder", variableMap);                                
       assertNotNull(processInstance.getId());
       System.out.println("id " + processInstance.getId() + " " 
           + processInstance.getProcessDefinitionId());
       List<Task> taskList = taskService.createTaskQuery()                
           .taskCandidateUser("kermit").list();                                                       
       assertEquals(taskList.size(), 1);
       for(Task task : taskList) {
         System.out.println("found task " + task.getName());
       }
     }
   }


I do a Junit test, but get the error:
Error while closing command context
org.activiti.engine.ActivitiException: Can't find scripting engine for 'groovy'
   at org.activiti.engine.impl.scripting.ScriptingEngines.evaluate(ScriptingEngines.java:66)
   at org.activiti.engine.impl.bpmn.behavior.ScriptTaskActivityBehavior.execute(ScriptTaskActivityBehavior.java:43)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationActivityExecute.execute(AtomicOperationActivityExecute.java:40)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:63)
   at org.activiti.engine.impl.runtime.ExecutionEntity.performOperation(ExecutionEntity.java:496)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerStart.eventNotificationsCompleted(AtomicOperationTransitionNotifyListenerStart.java:48)
   at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:52)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:63)
   at org.activiti.engine.impl.runtime.ExecutionEntity.performOperation(ExecutionEntity.java:496)
   at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:45)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:63)
   at org.activiti.engine.impl.runtime.ExecutionEntity.performOperation(ExecutionEntity.java:496)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionCreateScope.execute(AtomicOperationTransitionCreateScope.java:44)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:63)
   at org.activiti.engine.impl.runtime.ExecutionEntity.performOperation(ExecutionEntity.java:496)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerTake.execute(AtomicOperationTransitionNotifyListenerTake.java:61)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:63)
   at org.activiti.engine.impl.runtime.ExecutionEntity.performOperation(ExecutionEntity.java:496)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionDestroyScope.execute(AtomicOperationTransitionDestroyScope.java:111)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:63)
   at org.activiti.engine.impl.runtime.ExecutionEntity.performOperation(ExecutionEntity.java:496)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerEnd.eventNotificationsCompleted(AtomicOperationTransitionNotifyListenerEnd.java:36)
   at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:52)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:63)
   at org.activiti.engine.impl.runtime.ExecutionEntity.performOperation(ExecutionEntity.java:496)
   at org.activiti.engine.impl.runtime.ExecutionEntity.take(ExecutionEntity.java:341)
   at org.activiti.engine.impl.bpmn.behavior.BpmnActivityBehavior.performOutgoingBehavior(BpmnActivityBehavior.java:92)
   at org.activiti.engine.impl.bpmn.behavior.BpmnActivityBehavior.performDefaultOutgoingBehavior(BpmnActivityBehavior.java:49)
   at org.activiti.engine.impl.bpmn.behavior.FlowNodeActivityBehavior.leave(FlowNodeActivityBehavior.java:44)
   at org.activiti.engine.impl.bpmn.behavior.FlowNodeActivityBehavior.execute(FlowNodeActivityBehavior.java:36)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationActivityExecute.execute(AtomicOperationActivityExecute.java:40)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:63)
   at org.activiti.engine.impl.runtime.ExecutionEntity.performOperation(ExecutionEntity.java:496)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationProcessStartInitial.eventNotificationsCompleted(AtomicOperationProcessStartInitial.java:44)
   at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:52)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:63)
   at org.activiti.engine.impl.runtime.ExecutionEntity.performOperation(ExecutionEntity.java:496)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationProcessStart.eventNotificationsCompleted(AtomicOperationProcessStart.java:44)
   at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:52)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:63)
   at org.activiti.engine.impl.runtime.ExecutionEntity.performOperation(ExecutionEntity.java:496)
   at org.activiti.engine.impl.runtime.ExecutionEntity.start(ExecutionEntity.java:289)
   at org.activiti.engine.impl.cmd.StartProcessInstanceCmd.execute(StartProcessInstanceCmd.java:66)
   at org.activiti.engine.impl.cmd.StartProcessInstanceCmd.execute(StartProcessInstanceCmd.java:29)
   at org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24)
   at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:42)
   at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
   at org.activiti.engine.impl.RuntimeServiceImpl.startProcessInstanceByKey(RuntimeServiceImpl.java:49)
   at com.activiti.examples.bpmn.test.OrderInDetailTest.startBookOrder(OrderInDetailTest.java:39)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
   at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
   at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
   at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
   at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
   at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
   at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
   at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
   at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
   at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
   at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
   at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
   at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
   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)


this is  all that I had got. I saw someone used to post this problem tip, but I don't get what he called "asm 2.2.3.jar" in my tomcat path. and also I had my tomcat running the demo of activiti at the same time, I just want to test the bookorder test, and deploy it  in tomcat, please someone help~ :(

Outcomes