camunda-动态创建的模型在调用tasklistener类时导致“java.lang.classnotfoundexception”

py49o6xq  于 2021-07-03  发布在  Java
关注(0)|答案(2)|浏览(856)

我有一系列用xml定义的模型。我们现在有了一个动态创建模型所需的工具,而不需要xml文件和重启camundaweb应用程序。
我已经实现了动态模型并进行了部署(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(“”);是解决办法,但似乎什么都不管用!

i86rm4rw

i86rm4rw1#

传递给 DeploymentBuilder#addModelInstance 如果从文件系统部署动态创建的模型,则该模型将具有的文件名。这是一个有点不直观,但需要由卡蒙达部署机制。。。一个好的规则是附加 .bpmn 您的processdefinitionkey,所以这应该可以:

.createDeployment()
      .addModelInstance(
             "myProcess.bpmn", 
             BPMN.createExecutableProcess("myProcess")
                  ....
             .done()
      ).deploy();
3npbholx

3npbholx2#

我通过使用管理服务将部署注册到流程应用程序来解决这个问题

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);

在卡蒙达论坛的帮助下解决了这个问题

相关问题