Camunda Modeler : Service Task- Java Class

Hi,

Is it possible to give dynamic value in JAVA CLASS field while implementing service task as JAVA CLASS.

We want to read dynamic value from process variable as mentioned below.

“csAdapterName” variable has fully qualified java class path.

Currently we are getting below error-
org.camunda.bpm.engine.ProcessEngineException: ENGINE-09008 Exception while instantiating class ‘${execution.getVariable(“csAdapterName”)}’: ENGINE-09017 Cannot load class ‘${execution.getVariable(“csAdapterName”)}’: ${execution.getVariable(“csAdapterName”)}

Thanks,
Pradip Patil

@Pradip_Patil Dynamic class names will be supported in Expressions.

Try like this:

  <bpmn:process id="DynamicClassTesterProcess" name="Dynamic Class Tester" isExecutable="true">
    <bpmn:startEvent id="StartStartEvent" name="Start">
      <bpmn:extensionElements>
        <camunda:executionListener expression="${execution.setVariable(&#34;delegateClass&#34;,&#34;loggerDelegate.notify(execution)&#34;)}" event="start" />
      </bpmn:extensionElements>
      <bpmn:outgoing>Flow_0fdvekf</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:sequenceFlow id="Flow_0fdvekf" sourceRef="StartStartEvent" targetRef="LoadDynamicClassTask" />
    <bpmn:sequenceFlow id="Flow_1we5shz" sourceRef="LoadDynamicClassTask" targetRef="CheckExecutionTask" />
    <bpmn:endEvent id="EndEndEvent" name="End">
      <bpmn:incoming>Flow_1ofhyo4</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:sequenceFlow id="Flow_1ofhyo4" sourceRef="CheckExecutionTask" targetRef="EndEndEvent" />
    <bpmn:serviceTask id="LoadDynamicClassTask" name="Load Dynamic Class" camunda:asyncBefore="true" camunda:expression="${execution.getVariable(&#34;delegateClass&#34;)}">
      <bpmn:incoming>Flow_0fdvekf</bpmn:incoming>
      <bpmn:outgoing>Flow_1we5shz</bpmn:outgoing>
    </bpmn:serviceTask>
    <bpmn:userTask id="CheckExecutionTask" name="Check Execution" camunda:assignee="demo">
      <bpmn:incoming>Flow_1we5shz</bpmn:incoming>
      <bpmn:outgoing>Flow_1ofhyo4</bpmn:outgoing>
    </bpmn:userTask>
  </bpmn:process>

Here’s the Bpmn File: DynamicClassTesterProcess.bpmn (3.5 KB)

Delegate class:

@Slf4j
@Component
public class LoggerDelegate implements JavaDelegate {

	@Override
	public void execute(DelegateExecution execution) throws Exception {
		log.info("Logging for activity: {}", execution.getCurrentActivityName());
	}
}



1 Like

@aravindhrs This doesn’t work. The delegate function is never called