0
votes

I have simple bpmn process:

<?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:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_0m0cnse" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.2.0">
  <bpmn:process id="Process_1aegwvb" isExecutable="true">
    <bpmn:sequenceFlow id="Flow_1dfd8um" sourceRef="StartEvent_1" targetRef="Activity_047mv6x" />
    <bpmn:endEvent id="Event_1vradpp">
      <bpmn:incoming>Flow_19hnbhv</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:sequenceFlow id="Flow_19hnbhv" sourceRef="Activity_047mv6x" targetRef="Event_1vradpp" />
    <bpmn:startEvent id="StartEvent_1">
      <bpmn:outgoing>Flow_1dfd8um</bpmn:outgoing>
      <bpmn:timerEventDefinition id="TimerEventDefinition_1ah7red">
        <bpmn:timeCycle xsi:type="bpmn:tFormalExpression">0 0/5 * * * ?</bpmn:timeCycle>
      </bpmn:timerEventDefinition>
    </bpmn:startEvent>
    <bpmn:serviceTask id="Activity_047mv6x" name="Get users" camunda:class="*.Cron">
      <bpmn:incoming>Flow_1dfd8um</bpmn:incoming>
      <bpmn:outgoing>Flow_19hnbhv</bpmn:outgoing>
    </bpmn:serviceTask>
  </bpmn:process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1aegwvb">
      <bpmndi:BPMNEdge id="Flow_19hnbhv_di" bpmnElement="Flow_19hnbhv">
        <di:waypoint x="370" y="117" />
        <di:waypoint x="432" y="117" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_1dfd8um_di" bpmnElement="Flow_1dfd8um">
        <di:waypoint x="215" y="117" />
        <di:waypoint x="270" y="117" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="Event_1vradpp_di" bpmnElement="Event_1vradpp">
        <dc:Bounds x="432" y="99" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_11i5xth_di" bpmnElement="StartEvent_1">
        <dc:Bounds x="179" y="99" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_01expgb_di" bpmnElement="Activity_047mv6x">
        <dc:Bounds x="270" y="77" width="100" height="80" />
      </bpmndi:BPMNShape>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>
  1. jar file with Authentication provider classes and class Cron added into folders

camunda/webapps/engine-rest/WEB-INF/lib/ camunda/webapps/camunda/WEB-INF/lib/

If I start this process manually in Camunda Webapp or via REST API, it works fine and make needful job. But every 5 minutes I see problem in logs .

  1. Where do I need to add this class into classpath? It is a docker image with some extra features, custom authentication provider and so on.

  2. Cron.java:

    public class Cron implements JavaDelegate {

     @Override
     public void execute(DelegateExecution delegateExecution) {
         System.out.println("Test");
     }
    

    }

    24-Sep-2020 10:40:05.164 SEVERE [pool-2-thread-3] org.camunda.commons.logging.BaseLogger.logError ENGINE-16006 BPMN Stack Trace: Activity_047mv6x (activity-execute, ProcessInstance[4ed42252-fe52-11ea-9efd-12baf36f6a87]) Activity_047mv6x, name=Get users ^ | StartEvent_1

    24-Sep-2020 10:40:05.166 SEVERE [pool-2-thread-3] org.camunda.commons.logging.BaseLogger.logError ENGINE-16004 Exception while closing command context: ENGINE-09008 Exception while instantiating class '.Cron': ENGINE-09017 Cannot load class '.Cron': .Cron org.camunda.bpm.engine.ProcessEngineException: ENGINE-09008 Exception while instantiating class '.Cron': ENGINE-09017 Cannot load class '*.Cron': *.Cron at org.camunda.bpm.engine.impl.util.EngineUtilLogger.exceptionWhileInstantiatingClass(EngineUtilLogger.java:81)......................

    Caused by: java.lang.ClassNotFoundException: *.Cron at java.net.URLClassLoader.findClass(URLClassLoader.java:382) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) 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:87) ... 92 more

2

2 Answers

1
votes

Your process model contains a user task with implementation type Java Class. The Java Class name is set to: *.Cron So, when you run the process the engine is trying to find and instantiate a class of this name.

https://docs.camunda.org/manual/latest/user-guide/process-engine/delegation-code/

To implement a class that can be called during process execution, this class needs to implement the org.camunda.bpm.engine.delegate.JavaDelegate interface and provide the required logic in the execute method. When process execution arrives at this particular step, it will execute this logic defined in that method and leave the activity in the default BPMN 2.0 way.

You need to change the process model to reference a class which actually exists (https://docs.camunda.org/manual/latest/reference/bpmn20/tasks/service-task/) or use another implementation approach.

Your Docker image is likely based on Camunda BPM run. In this distribution additional jars can be placed in the userlib folder. https://docs.camunda.org/manual/latest/user-guide/camunda-bpm-run/ However, since you do not seem to be right at home in the Java world, you may want to consider a different approach to invoke your service. You could for instance change the implementation of your service task to a script tasks or to an external service task

https://docs.camunda.org/manual/latest/reference/bpmn20/tasks/script-task/

https://docs.camunda.org/manual/latest/reference/bpmn20/tasks/service-task/

-1
votes

Solved problem by creating distinct module with Cron class packaging war. And then add it as one more web application.