Camunda - 动态创建的模型在调用 TaskListener class 时导致 "java.lang.ClassNotFoundException"
Camunda - Dynamically created model causes "java.lang.ClassNotFoundException" when calling TaskListener class
我在XML中定义了一系列模型。我们现在需要动态创建模型,而不需要 XML 文件和任何重新启动 Camunda 网络应用程序。
我已经实现了动态模型并进行部署(modelInstance 是一个 BpmnModelInstance 对象):
BpmPlatform.getProcessEngineService()
.getProcessEngine("default")
.getRepositoryService()
.createDeployment().addModelInstance("bpmn", modelInstance)
.deploy();
但是在部署和实例化模型时抛出以下错误:
Caused by: org.camunda.bpm.engine.ProcessEngineException: ENGINE-09008 Exception while instantiating class 'org.camunda.bpm.utility.AssignmentAPINotify': ENGINE-09017 Cannot load class 'org.camunda.bpm.utility.AssignmentAPINotify': org.camunda.bpm.utility.AssignmentAPINotify
at org.camunda.bpm.engine.impl.util.EngineUtilLogger.exceptionWhileInstantiatingClass(EngineUtilLogger.java:78)
at org.camunda.bpm.engine.impl.util.ClassDelegateUtil.instantiateDelegate(ClassDelegateUtil.java:50)
at org.camunda.bpm.engine.impl.task.listener.ClassDelegateTaskListener.getTaskListenerInstance(ClassDelegateTaskListener.java:54)
at org.camunda.bpm.engine.impl.task.listener.ClassDelegateTaskListener.notify(ClassDelegateTaskListener.java:42)
at org.camunda.bpm.engine.impl.task.delegate.TaskListenerInvocation.invoke(TaskListenerInvocation.java:41)
at org.camunda.bpm.engine.impl.delegate.DelegateInvocation.proceed(DelegateInvocation.java:54)
at org.camunda.bpm.engine.impl.delegate.DefaultDelegateInterceptor.handleInvocationInContext(DefaultDelegateInterceptor.java:87)
at org.camunda.bpm.engine.impl.delegate.DefaultDelegateInterceptor.handleInvocation(DefaultDelegateInterceptor.java:59)
at org.camunda.bpm.engine.impl.persistence.entity.TaskEntity.fireEvent(TaskEntity.java:956)
... 119 more
Caused by: org.camunda.bpm.engine.ClassLoadingException: ENGINE-09017 Cannot load class 'org.camunda.bpm.utility.AssignmentAPINotify': org.camunda.bpm.utility.AssignmentAPINotify
at org.camunda.bpm.engine.impl.util.EngineUtilLogger.classLoadingException(EngineUtilLogger.java:135)
at org.camunda.bpm.engine.impl.util.ReflectUtil.loadClass(ReflectUtil.java:107)
at org.camunda.bpm.engine.impl.util.ClassDelegateUtil.instantiateDelegate(ClassDelegateUtil.java:42)
... 126 more
Caused by: java.lang.ClassNotFoundException: org.camunda.bpm.utility.AssignmentAPINotify
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1275)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1104)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at org.camunda.bpm.engine.impl.util.ReflectUtil.loadClass(ReflectUtil.java:84)
... 127 more
如果我将模型保存为 XML 并重新启动,则没有任何问题。
我一直在看 deploymentBuilder.addClasspathResource("");是解决方案,但似乎没有任何效果!
您传递给 DeploymentBuilder#addModelInstance
的“resourceName”是您动态创建的模型在从文件系统部署它时将具有的文件名。这有点不直观,但 Camunda 部署机制要求......一个好的规则是将 .bpmn
附加到你的 processDefinitionKey,所以这应该有效:
.createDeployment()
.addModelInstance(
"myProcess.bpmn",
BPMN.createExecutableProcess("myProcess")
....
.done()
).deploy();
我通过使用管理服务将部署注册到流程应用程序解决了这个问题
ProcessEngine processEngine = BpmPlatform.getProcessEngineService().getDefaultProcessEngine();
DeploymentBuilder deploymentBuilder = processEngine.getRepositoryService().createDeployment();
deploymentBuilder = deploymentBuilder.addModelInstance(name, modelInstance);
Deployment deployment = deploymentBuilder.deploy();
ManagementService managementService = processEngine.getManagementService();
managementService.registerProcessApplication(deployment.getId(), PROCESS_APPLICATION_REFERENCE);
在 Camunda 论坛的帮助下解决了 here is the thread
我在XML中定义了一系列模型。我们现在需要动态创建模型,而不需要 XML 文件和任何重新启动 Camunda 网络应用程序。
我已经实现了动态模型并进行部署(modelInstance 是一个 BpmnModelInstance 对象):
BpmPlatform.getProcessEngineService()
.getProcessEngine("default")
.getRepositoryService()
.createDeployment().addModelInstance("bpmn", modelInstance)
.deploy();
但是在部署和实例化模型时抛出以下错误:
Caused by: org.camunda.bpm.engine.ProcessEngineException: ENGINE-09008 Exception while instantiating class 'org.camunda.bpm.utility.AssignmentAPINotify': ENGINE-09017 Cannot load class 'org.camunda.bpm.utility.AssignmentAPINotify': org.camunda.bpm.utility.AssignmentAPINotify
at org.camunda.bpm.engine.impl.util.EngineUtilLogger.exceptionWhileInstantiatingClass(EngineUtilLogger.java:78)
at org.camunda.bpm.engine.impl.util.ClassDelegateUtil.instantiateDelegate(ClassDelegateUtil.java:50)
at org.camunda.bpm.engine.impl.task.listener.ClassDelegateTaskListener.getTaskListenerInstance(ClassDelegateTaskListener.java:54)
at org.camunda.bpm.engine.impl.task.listener.ClassDelegateTaskListener.notify(ClassDelegateTaskListener.java:42)
at org.camunda.bpm.engine.impl.task.delegate.TaskListenerInvocation.invoke(TaskListenerInvocation.java:41)
at org.camunda.bpm.engine.impl.delegate.DelegateInvocation.proceed(DelegateInvocation.java:54)
at org.camunda.bpm.engine.impl.delegate.DefaultDelegateInterceptor.handleInvocationInContext(DefaultDelegateInterceptor.java:87)
at org.camunda.bpm.engine.impl.delegate.DefaultDelegateInterceptor.handleInvocation(DefaultDelegateInterceptor.java:59)
at org.camunda.bpm.engine.impl.persistence.entity.TaskEntity.fireEvent(TaskEntity.java:956)
... 119 more
Caused by: org.camunda.bpm.engine.ClassLoadingException: ENGINE-09017 Cannot load class 'org.camunda.bpm.utility.AssignmentAPINotify': org.camunda.bpm.utility.AssignmentAPINotify
at org.camunda.bpm.engine.impl.util.EngineUtilLogger.classLoadingException(EngineUtilLogger.java:135)
at org.camunda.bpm.engine.impl.util.ReflectUtil.loadClass(ReflectUtil.java:107)
at org.camunda.bpm.engine.impl.util.ClassDelegateUtil.instantiateDelegate(ClassDelegateUtil.java:42)
... 126 more
Caused by: java.lang.ClassNotFoundException: org.camunda.bpm.utility.AssignmentAPINotify
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1275)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1104)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at org.camunda.bpm.engine.impl.util.ReflectUtil.loadClass(ReflectUtil.java:84)
... 127 more
如果我将模型保存为 XML 并重新启动,则没有任何问题。
我一直在看 deploymentBuilder.addClasspathResource("");是解决方案,但似乎没有任何效果!
您传递给 DeploymentBuilder#addModelInstance
的“resourceName”是您动态创建的模型在从文件系统部署它时将具有的文件名。这有点不直观,但 Camunda 部署机制要求......一个好的规则是将 .bpmn
附加到你的 processDefinitionKey,所以这应该有效:
.createDeployment()
.addModelInstance(
"myProcess.bpmn",
BPMN.createExecutableProcess("myProcess")
....
.done()
).deploy();
我通过使用管理服务将部署注册到流程应用程序解决了这个问题
ProcessEngine processEngine = BpmPlatform.getProcessEngineService().getDefaultProcessEngine();
DeploymentBuilder deploymentBuilder = processEngine.getRepositoryService().createDeployment();
deploymentBuilder = deploymentBuilder.addModelInstance(name, modelInstance);
Deployment deployment = deploymentBuilder.deploy();
ManagementService managementService = processEngine.getManagementService();
managementService.registerProcessApplication(deployment.getId(), PROCESS_APPLICATION_REFERENCE);
在 Camunda 论坛的帮助下解决了 here is the thread