我在包含业务规则任务的 Activiti 进程中进行 JUnit测试。我在DRL文件中实现了业务规则(从Excel Drools Decision Table 生成)。最后一次成功测试了。
我的单元测试在下面的部署指令失败:
RepositoryService repositoryService = activitiRule
.getRepositoryService();
repositoryService
.createDeployment()
.addClasspathResource(ruleFile)
.addClasspathResource(bpmn20File)
.deploy();
相关的堆栈跟踪:
java.lang.IncompatibleClassChangeError: Implementing class
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:455)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:367)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.drools.rule.builder.RuleBuildContext.<init>(RuleBuildContext.java:73)
at org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:2825)
at org.drools.compiler.PackageBuilder.compileRules(PackageBuilder.java:970)
at org.drools.compiler.PackageBuilder.compileAllRules(PackageBuilder.java:879)
at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:871)
at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:466)
at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:694)
at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:51)
at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:40)
at org.activiti.engine.impl.rules.RulesDeployer.deploy(RulesDeployer.java:59)
at org.activiti.engine.impl.persistence.deploy.DeploymentManager.deploy(DeploymentManager.java:50)
at org.activiti.engine.impl.cmd.DeployCmd.execute(DeployCmd.java:103)
at org.activiti.engine.impl.cmd.DeployCmd.execute(DeployCmd.java:37)
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:78)
at org.activiti.engine.impl.repository.DeploymentBuilderImpl.deploy(DeploymentBuilderImpl.java:156)
at com.capgemini.com.XXX.iors.bpm.router.test.RouterProcessTest.startProcess(RouterProcessTest.java:43)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
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:126)
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:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
关联的DRL文件:
package com.capgemini.com.XXX.iors.bpm.router.rules;
//generated from Decision Table
import com.capgemini.com.XXX.iors.bpm.router.rules.*;
global com.capgemini.com.XXX.iors.bpm.router.rules.RouterResult result;
// rule values at C11, header at C6
rule "RouterRule_11"
when
r:RouterInput(origin in ("system"), fileName.equals("System"))
then
result.setProcessIdentifier("SystemProcess");
end
// rule values at C12, header at C6
rule "RouterRule_12"
when
r:RouterInput(origin in ("contracts", "contract"), fileName.equals("contract"))
then
result.setProcessIdentifier("ContractProcess");
end
// rule values at C13, header at C6
rule "RouterRule_13"
when
r:RouterInput(origin in ("contracts", "contract"), fileName.equals("advcontract"))
then
result.setProcessIdentifier("AdvancedContractProcess");
end
[EDIT1] 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:xsd="http://www.w3.org/2001/XMLSchema" 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="myProcess" name="My process" isExecutable="true">
<startEvent id="startevent1" name="Start"></startEvent>
<endEvent id="endevent2" name="End"></endEvent>
<businessRuleTask id="routingTask" name="Routing Taks" activiti:ruleVariablesInput="${routerInput}" activiti:resultVariable="rulesOutput"></businessRuleTask>
<sequenceFlow id="flow4" sourceRef="startevent1" targetRef="routingTask"></sequenceFlow>
<sequenceFlow id="flow5" sourceRef="routingTask" targetRef="endevent2"></sequenceFlow>
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_myProcess">
<bpmndi:BPMNPlane bpmnElement="myProcess" id="BPMNPlane_myProcess">
<bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
<omgdc:Bounds height="35.0" width="35.0" x="110.0" y="170.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="endevent2" id="BPMNShape_endevent2">
<omgdc:Bounds height="35.0" width="35.0" x="360.0" y="170.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="routingTask" id="BPMNShape_routingTask">
<omgdc:Bounds height="55.0" width="105.0" x="190.0" y="160.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
<omgdi:waypoint x="145.0" y="187.0"></omgdi:waypoint>
<omgdi:waypoint x="190.0" y="187.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow5" id="BPMNEdge_flow5">
<omgdi:waypoint x="295.0" y="187.0"></omgdi:waypoint>
<omgdi:waypoint x="360.0" y="187.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
RouterInput和RouterResult类是传递给 Activiti ruleVariablesInput&amp;的简单getter / setter类。 ruleVariablesOuput fields 在我的业务规则任务上执行I / O.
我怎样才能解决这个IncompatibleClassChangeError问题?
提前致谢。
答案 0 :(得分:0)
这是由于我的Pom.xml中指定的 Mvel2依赖版本(2.2.1.Final)与drools库导入的版本之间存在冲突。
见下文 Maven依赖关系层次结构: