camunda 异常找不到 ID 任务为空的任务
camunda exception Cannot find task with id task is null
首先我想说我已经看到了这个问题: 而这个问题不是我的问题。
我使用 jersey 构建了一个休息 api,我正在使用 camunda 工作流引擎。
我使用了 jersey-quickstart-grizzly maven archtype,然后像这样定义了进程资源:
@Path("process")
public class Process {
/**
* Method handling HTTP GET requests. The returned object will be sent
* to the client as "text/plain" media type.
*
*/
@POST
@Produces(MediaType.APPLICATION_JSON)
@Path("start")
public void start(){
ProcessEngineManager.getEngine().getRuntimeService().startProcessInstanceByKey("test");
}
@POST
@Produces(MediaType.APPLICATION_JSON)
@Path("next")
public void next(@FormParam("name") String name){
Map<String,Object> formParams = new HashMap<>();
formParams.put("name",name);
ProcessEngineManager.getEngine().getFormService().submitTaskForm("testtask",formParams);
}
}
这是 ProcessEngineManager.java :
import org.camunda.bpm.engine.ProcessEngine;
import org.camunda.bpm.engine.ProcessEngines;
public class ProcessEngineManager {
private static ProcessEngine engine;
public static ProcessEngine getEngine(){
if(engine==null) {
engine = ProcessEngines.getDefaultProcessEngine();
engine.getRepositoryService().createDeployment()
.addClasspathResource("workflowtest/test.bpmn")
.deploy();
}
return engine;
}
}
我在 src/main/resources/workflowtest 下定义了 test.bpmn,如下所示:
在 Xml 中:
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.11.3">
<bpmn:process id="test" isExecutable="true">
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>SequenceFlow_1v6clcy</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:sequenceFlow id="SequenceFlow_1v6clcy" sourceRef="StartEvent_1" targetRef="testtask" />
<bpmn:userTask id="testtask" name="testtask" camunda:formKey="testform">
<bpmn:extensionElements>
<camunda:formData>
<camunda:formField id="name" label="name" type="string" />
</camunda:formData>
</bpmn:extensionElements>
<bpmn:incoming>SequenceFlow_1v6clcy</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_07kdfp4</bpmn:outgoing>
</bpmn:userTask>
<bpmn:endEvent id="EndEvent_0vm605w">
<bpmn:incoming>SequenceFlow_07kdfp4</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="SequenceFlow_07kdfp4" sourceRef="testtask" targetRef="EndEvent_0vm605w" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="test">
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds x="173" y="102" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_1v6clcy_di" bpmnElement="SequenceFlow_1v6clcy">
<di:waypoint xsi:type="dc:Point" x="209" y="120" />
<di:waypoint xsi:type="dc:Point" x="275" y="120" />
<bpmndi:BPMNLabel>
<dc:Bounds x="242" y="99" width="0" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="UserTask_1s01hea_di" bpmnElement="testtask">
<dc:Bounds x="275" y="80" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="EndEvent_0vm605w_di" bpmnElement="EndEvent_0vm605w">
<dc:Bounds x="437" y="101" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="455" y="141" width="0" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_07kdfp4_di" bpmnElement="SequenceFlow_07kdfp4">
<di:waypoint xsi:type="dc:Point" x="375" y="120" />
<di:waypoint xsi:type="dc:Point" x="403" y="120" />
<di:waypoint xsi:type="dc:Point" x="403" y="119" />
<di:waypoint xsi:type="dc:Point" x="437" y="119" />
<bpmndi:BPMNLabel>
<dc:Bounds x="418" y="113.5" width="0" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
我在 src/main/resources 下有 camunda.cfg.xml 定义如下:
<beans xmlns="http://www.springframework.org/schema/beans"
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">
<bean id="processEngineConfiguration"
class="org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration">
<property name="jdbcUrl" value="jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000" />
<property name="jdbcDriver" value="org.h2.Driver" />
<property name="jdbcUsername" value="sa" />
<property name="jdbcPassword" value="" />
<property name="databaseSchemaUpdate" value="true" />
</bean>
</beans>
我正在使用 curl 测试我的 api,我验证了 curl -X POST http://localhost:8080/process/start
工作并启动了一个进程,之后我 curl -X POST -d '{name: "John"}' http://localhost:8080/process/next
并且我在服务器控制台中看到了这个异常:
org.camunda.bpm.engine.exception.NullValueException: Cannot find task
with id testtask: task is null at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
~[?:1.8.0_151] at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
~[?:1.8.0_151] at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
~[?:1.8.0_151] at
java.lang.reflect.Constructor.newInstance(Constructor.java:423)
~[?:1.8.0_151] at
org.camunda.bpm.engine.impl.util.EnsureUtil.generateException(EnsureUtil.java:344)
~[camunda-engine-7.8.0.jar:7.8.0] at
org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull(EnsureUtil.java:49)
~[camunda-engine-7.8.0.jar:7.8.0] at
org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull(EnsureUtil.java:44)
~[camunda-engine-7.8.0.jar:7.8.0] at
org.camunda.bpm.engine.impl.cmd.SubmitTaskFormCmd.execute(SubmitTaskFormCmd.java:54)
~[camunda-engine-7.8.0.jar:7.8.0] at
org.camunda.bpm.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24)
~[camunda-engine-7.8.0.jar:7.8.0] at
org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:104)
~[camunda-engine-7.8.0.jar:7.8.0] at
org.camunda.bpm.engine.impl.interceptor.ProcessApplicationContextInterceptor.execute(ProcessApplicationContextInterceptor.java:66)
~[camunda-engine-7.8.0.jar:7.8.0] at
org.camunda.bpm.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:30)
~[camunda-engine-7.8.0.jar:7.8.0] at
org.camunda.bpm.engine.impl.FormServiceImpl.submitTaskForm(FormServiceImpl.java:88)
~[camunda-engine-7.8.0.jar:7.8.0] at
workflowtest.Process.next(Process.java:37) ~[classes/:?] at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
~[?:1.8.0_151] at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
~[?:1.8.0_151] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
~[?:1.8.0_151] at java.lang.reflect.Method.invoke(Method.java:498)
~[?:1.8.0_151] at
org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static[=16=](ResourceMethodInvocationHandlerFactory.java:76)
~[jersey-server-2.26.jar:?] at
org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.run(AbstractJavaResourceMethodDispatcher.java:148)
[jersey-server-2.26.jar:?] at
org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:191)
[jersey-server-2.26.jar:?] at
org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$VoidOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:183)
[jersey-server-2.26.jar:?] at
org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:103)
[jersey-server-2.26.jar:?] at
org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:493)
[jersey-server-2.26.jar:?] at
org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:415)
[jersey-server-2.26.jar:?] at
org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:104)
[jersey-server-2.26.jar:?] at
org.glassfish.jersey.server.ServerRuntime.run(ServerRuntime.java:277)
[jersey-server-2.26.jar:?] at
org.glassfish.jersey.internal.Errors.call(Errors.java:272)
[jersey-common-2.26.jar:?] at
org.glassfish.jersey.internal.Errors.call(Errors.java:268)
[jersey-common-2.26.jar:?] at
org.glassfish.jersey.internal.Errors.process(Errors.java:316)
[jersey-common-2.26.jar:?] at
org.glassfish.jersey.internal.Errors.process(Errors.java:298)
[jersey-common-2.26.jar:?] at
org.glassfish.jersey.internal.Errors.process(Errors.java:268)
[jersey-common-2.26.jar:?] at
org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:289)
[jersey-common-2.26.jar:?] at
org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:256)
[jersey-server-2.26.jar:?] at
org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:703)
[jersey-server-2.26.jar:?] at
org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer.service(GrizzlyHttpContainer.java:377)
[jersey-container-grizzly2-http-2.26.jar:?] at
org.glassfish.grizzly.http.server.HttpHandler.run(HttpHandler.java:224)
[grizzly-http-server-2.4.0.jar:2.4.0] at
org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:593)
[grizzly-framework-2.4.0.jar:2.4.0] at
org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:573)
[grizzly-framework-2.4.0.jar:2.4.0] at
java.lang.Thread.run(Thread.java:748) [?:1.8.0_151]
我不明白为什么?它确实启动了进程,因此它找到了进程 "test" 而不是任务 "testtask",这是为什么以及如何解决这个问题?
大目标
这个项目只是对我们想要构建的工作流管理系统的一个想法的测试,我们想要测试的想法是我们可以用我们自己的方式构建表单以获得它的选项 select 从我们自己的数据库输入,仍然使用 camunda 作为工作流引擎。
testTask
是进程中用户任务的 ID,但不是 Camunda 在执行流到达 activity 时在运行时创建的任务的 ID。您可以通过TaskService#createTaskQuery
获取任务。这应该 return 在您的示例中产生一个结果。然后通过 Task#getId
获取 ID 并将其用作调用 FormService#submitTaskForm
.
的参数
为什么会这样?您可以有多个流程实例,因此每个 BPMN 可以有多个实例 activity。然后,activity ID 不能唯一标识单个任务实例。
当 test
是流程模型中的 ID 时,为什么使用 test
启动流程实例有效?这在 Camunda 术语中称为 process key
,当您以这种方式启动流程实例时,它始终引用具有该键的流程定义的最新版本。
首先我想说我已经看到了这个问题:
我使用 jersey 构建了一个休息 api,我正在使用 camunda 工作流引擎。
我使用了 jersey-quickstart-grizzly maven archtype,然后像这样定义了进程资源:
@Path("process")
public class Process {
/**
* Method handling HTTP GET requests. The returned object will be sent
* to the client as "text/plain" media type.
*
*/
@POST
@Produces(MediaType.APPLICATION_JSON)
@Path("start")
public void start(){
ProcessEngineManager.getEngine().getRuntimeService().startProcessInstanceByKey("test");
}
@POST
@Produces(MediaType.APPLICATION_JSON)
@Path("next")
public void next(@FormParam("name") String name){
Map<String,Object> formParams = new HashMap<>();
formParams.put("name",name);
ProcessEngineManager.getEngine().getFormService().submitTaskForm("testtask",formParams);
}
}
这是 ProcessEngineManager.java :
import org.camunda.bpm.engine.ProcessEngine;
import org.camunda.bpm.engine.ProcessEngines;
public class ProcessEngineManager {
private static ProcessEngine engine;
public static ProcessEngine getEngine(){
if(engine==null) {
engine = ProcessEngines.getDefaultProcessEngine();
engine.getRepositoryService().createDeployment()
.addClasspathResource("workflowtest/test.bpmn")
.deploy();
}
return engine;
}
}
我在 src/main/resources/workflowtest 下定义了 test.bpmn,如下所示:
在 Xml 中:
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.11.3">
<bpmn:process id="test" isExecutable="true">
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>SequenceFlow_1v6clcy</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:sequenceFlow id="SequenceFlow_1v6clcy" sourceRef="StartEvent_1" targetRef="testtask" />
<bpmn:userTask id="testtask" name="testtask" camunda:formKey="testform">
<bpmn:extensionElements>
<camunda:formData>
<camunda:formField id="name" label="name" type="string" />
</camunda:formData>
</bpmn:extensionElements>
<bpmn:incoming>SequenceFlow_1v6clcy</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_07kdfp4</bpmn:outgoing>
</bpmn:userTask>
<bpmn:endEvent id="EndEvent_0vm605w">
<bpmn:incoming>SequenceFlow_07kdfp4</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="SequenceFlow_07kdfp4" sourceRef="testtask" targetRef="EndEvent_0vm605w" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="test">
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds x="173" y="102" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_1v6clcy_di" bpmnElement="SequenceFlow_1v6clcy">
<di:waypoint xsi:type="dc:Point" x="209" y="120" />
<di:waypoint xsi:type="dc:Point" x="275" y="120" />
<bpmndi:BPMNLabel>
<dc:Bounds x="242" y="99" width="0" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="UserTask_1s01hea_di" bpmnElement="testtask">
<dc:Bounds x="275" y="80" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="EndEvent_0vm605w_di" bpmnElement="EndEvent_0vm605w">
<dc:Bounds x="437" y="101" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="455" y="141" width="0" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_07kdfp4_di" bpmnElement="SequenceFlow_07kdfp4">
<di:waypoint xsi:type="dc:Point" x="375" y="120" />
<di:waypoint xsi:type="dc:Point" x="403" y="120" />
<di:waypoint xsi:type="dc:Point" x="403" y="119" />
<di:waypoint xsi:type="dc:Point" x="437" y="119" />
<bpmndi:BPMNLabel>
<dc:Bounds x="418" y="113.5" width="0" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
我在 src/main/resources 下有 camunda.cfg.xml 定义如下:
<beans xmlns="http://www.springframework.org/schema/beans"
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">
<bean id="processEngineConfiguration"
class="org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration">
<property name="jdbcUrl" value="jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000" />
<property name="jdbcDriver" value="org.h2.Driver" />
<property name="jdbcUsername" value="sa" />
<property name="jdbcPassword" value="" />
<property name="databaseSchemaUpdate" value="true" />
</bean>
</beans>
我正在使用 curl 测试我的 api,我验证了 curl -X POST http://localhost:8080/process/start
工作并启动了一个进程,之后我 curl -X POST -d '{name: "John"}' http://localhost:8080/process/next
并且我在服务器控制台中看到了这个异常:
org.camunda.bpm.engine.exception.NullValueException: Cannot find task with id testtask: task is null at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_151] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_151] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_151] at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_151] at org.camunda.bpm.engine.impl.util.EnsureUtil.generateException(EnsureUtil.java:344) ~[camunda-engine-7.8.0.jar:7.8.0] at org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull(EnsureUtil.java:49) ~[camunda-engine-7.8.0.jar:7.8.0] at org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull(EnsureUtil.java:44) ~[camunda-engine-7.8.0.jar:7.8.0] at org.camunda.bpm.engine.impl.cmd.SubmitTaskFormCmd.execute(SubmitTaskFormCmd.java:54) ~[camunda-engine-7.8.0.jar:7.8.0] at org.camunda.bpm.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24) ~[camunda-engine-7.8.0.jar:7.8.0] at org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:104) ~[camunda-engine-7.8.0.jar:7.8.0] at org.camunda.bpm.engine.impl.interceptor.ProcessApplicationContextInterceptor.execute(ProcessApplicationContextInterceptor.java:66) ~[camunda-engine-7.8.0.jar:7.8.0] at org.camunda.bpm.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:30) ~[camunda-engine-7.8.0.jar:7.8.0] at org.camunda.bpm.engine.impl.FormServiceImpl.submitTaskForm(FormServiceImpl.java:88) ~[camunda-engine-7.8.0.jar:7.8.0] at workflowtest.Process.next(Process.java:37) ~[classes/:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_151] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_151] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_151] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_151] at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static[=16=](ResourceMethodInvocationHandlerFactory.java:76) ~[jersey-server-2.26.jar:?] at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.run(AbstractJavaResourceMethodDispatcher.java:148) [jersey-server-2.26.jar:?] at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:191) [jersey-server-2.26.jar:?] at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$VoidOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:183) [jersey-server-2.26.jar:?] at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:103) [jersey-server-2.26.jar:?] at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:493) [jersey-server-2.26.jar:?] at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:415) [jersey-server-2.26.jar:?] at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:104) [jersey-server-2.26.jar:?] at org.glassfish.jersey.server.ServerRuntime.run(ServerRuntime.java:277) [jersey-server-2.26.jar:?] at org.glassfish.jersey.internal.Errors.call(Errors.java:272) [jersey-common-2.26.jar:?] at org.glassfish.jersey.internal.Errors.call(Errors.java:268) [jersey-common-2.26.jar:?] at org.glassfish.jersey.internal.Errors.process(Errors.java:316) [jersey-common-2.26.jar:?] at org.glassfish.jersey.internal.Errors.process(Errors.java:298) [jersey-common-2.26.jar:?] at org.glassfish.jersey.internal.Errors.process(Errors.java:268) [jersey-common-2.26.jar:?] at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:289) [jersey-common-2.26.jar:?] at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:256) [jersey-server-2.26.jar:?] at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:703) [jersey-server-2.26.jar:?] at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer.service(GrizzlyHttpContainer.java:377) [jersey-container-grizzly2-http-2.26.jar:?] at org.glassfish.grizzly.http.server.HttpHandler.run(HttpHandler.java:224) [grizzly-http-server-2.4.0.jar:2.4.0] at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:593) [grizzly-framework-2.4.0.jar:2.4.0] at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:573) [grizzly-framework-2.4.0.jar:2.4.0] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_151]
我不明白为什么?它确实启动了进程,因此它找到了进程 "test" 而不是任务 "testtask",这是为什么以及如何解决这个问题?
大目标
这个项目只是对我们想要构建的工作流管理系统的一个想法的测试,我们想要测试的想法是我们可以用我们自己的方式构建表单以获得它的选项 select 从我们自己的数据库输入,仍然使用 camunda 作为工作流引擎。
testTask
是进程中用户任务的 ID,但不是 Camunda 在执行流到达 activity 时在运行时创建的任务的 ID。您可以通过TaskService#createTaskQuery
获取任务。这应该 return 在您的示例中产生一个结果。然后通过 Task#getId
获取 ID 并将其用作调用 FormService#submitTaskForm
.
为什么会这样?您可以有多个流程实例,因此每个 BPMN 可以有多个实例 activity。然后,activity ID 不能唯一标识单个任务实例。
当 test
是流程模型中的 ID 时,为什么使用 test
启动流程实例有效?这在 Camunda 术语中称为 process key
,当您以这种方式启动流程实例时,它始终引用具有该键的流程定义的最新版本。