cancel
Showing results for 
Search instead for 
Did you mean: 

Compensation Mechanism

gokceng
Champ in-the-making
Champ in-the-making
Hi,
I've been trying compensation in my very simple process but I couldn't make it work. I'm looking at http://activiti.org/userguide/#bpmnBoundaryCompensationEvent

You can look at my process definition here:
<?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://activiti.org/bpmn20">
   <process id="activitiAdhoc" name="Adhoc Activiti Process">
      <startEvent id="start"></startEvent>
      <endEvent id="theEnd"></endEvent>
      <scriptTask id="scripttask1" name="Ad-Hoc Task"
         scriptFormat="groovy">
         <script><![CDATA[out:println "Ad-Hoc Task";]]></script>
      </scriptTask>
      <serviceTask id="servicetask1" name="Verify Ad-Hoc Task"
         activiti:class="service.VerifyAdHocService"></serviceTask>
      <boundaryEvent id="myCompensationEvent" attachedToRef="servicetask1">
         <compensateEventDefinition></compensateEventDefinition>
      </boundaryEvent>
      <association associationDirection="One" id="a1"
         sourceRef="myCompensationEvent" targetRef="servicetask2" />
      <serviceTask id="servicetask2" name="Compensation Service Task"
         isForCompensation="true" activiti:class="service.AdHocCompensationService"></serviceTask>
      <sequenceFlow id="flow4" name="" sourceRef="start"
         targetRef="scripttask1"></sequenceFlow>
      <sequenceFlow id="flow5" name="" sourceRef="servicetask1"
         targetRef="theEnd"></sequenceFlow>
      <sequenceFlow id="flow6" name="" sourceRef="scripttask1"
         targetRef="servicetask1"></sequenceFlow>
   </process>
   <bpmndi:BPMNDiagram id="BPMNDiagram_activitiAdhoc">
      <!– Excluded –>
   </bpmndi:BPMNDiagram>
</definitions>

service.* classes are plain extensions of JavaDelegate and consist of System.out.println calls.

I'm getting this error:
org.activiti.engine.ActivitiException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'serviceTask'. One of '{"http://www.omg.org/spec/BPMN/20100524/MODEL':artifact, "http://www.omg.org/spec/BPMN/20100524/MODEL':resourceRole, "http://www.omg.org/spec/BPMN/20100524/MODEL':correlationSubscription, "http://www.omg.org/spec/BPMN/20100524/MODEL':supports}' is expected. | diagrams/MyProcess.bpmn | line 25 | column 79

   at org.activiti.engine.impl.util.xml.Parse.throwActivitiExceptionForErrors(Parse.java:186)
   at org.activiti.engine.impl.bpmn.parser.BpmnParse.execute(BpmnParse.java:237)
   at org.activiti.engine.impl.bpmn.deployer.BpmnDeployer.deploy(BpmnDeployer.java:90)
   at org.activiti.engine.impl.persistence.deploy.DeploymentCache.deploy(DeploymentCache.java:38)
   at org.activiti.engine.impl.persistence.entity.DeploymentManager.insertDeployment(DeploymentManager.java:42)
   at org.activiti.engine.impl.cmd.DeployCmd.execute(DeployCmd.java:59)
   at org.activiti.engine.impl.cmd.DeployCmd.execute(DeployCmd.java:31)
   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.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:42)
   at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)
   at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:40)
   at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
   at org.activiti.engine.impl.RepositoryServiceImpl.deploy(RepositoryServiceImpl.java:54)
   at org.activiti.engine.impl.repository.DeploymentBuilderImpl.deploy(DeploymentBuilderImpl.java:106)
   at org.activiti.engine.impl.test.TestHelper.annotationDeploymentSetUp(TestHelper.java:98)
   at org.activiti.engine.test.ActivitiRule.starting(ActivitiRule.java:100)
   at org.junit.rules.TestWatchman$1.evaluate(TestWatchman.java:46)
   at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
   at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
   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.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
   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:236)
   at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
   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)

I couldn't find the problem here, I couldn't compensation examples anywhere also, they are just XML snippets.
I need to unit test this compensation issue, too. How can I make process instance to be compensated?
1 REPLY 1

jbarrez
Star Contributor
Star Contributor