Access Java Delegate from a Standalone

Hi guys, I have a problem with a Java Delegate implementation
I have a Camunda engine running as standalone (using the bundle that came with Apache Tomcat)
The thing is I made a simple process that has a Service Task configured as Java Delegate.
The Java delegate class was deployed as war inside the “webapp” folder as the documentation said.
The thing is, as is expected, that Java Delegate implementation is not visible from the process I made.
Every time I execute the process I get this error:

ENGINE-09008 Exception while instantiating class 'com.poc.mc.camundawask.business.DummyDelegate': ENGINE-09017 Cannot load class 'com.poc.mc.camundawask.business.DummyDelegate': com.poc.mc.camundawask.business.DummyDelegate"

So, my question is. What I’m missing? Should I change the classloader into the standalone app?

Thanks in advance,
Diego

@dscheinin how do you configure delegates in BPMN file?

Hi @aravindhrs

I tried two ways of configuring Delegates.
As Java Class
<bpmn:serviceTask id="Task_0bhpj8i" name="toUpper" camunda:class="com. poc. mc. camundawask. business. DummyDelegate">

As Delegate Expression
<bpmn:serviceTask id="Task_0bhpj8i" name="toUpper" camunda:delegateExpression="com.poc.mc.camundawask.business.DumdiferentmyDelegate">

As Delegate Expression I’m getting a slightly different error:

ENGINE-02033 Delegate Expression 'com. poc. mc. camundawask. business. DummyDelegate' did neither resolve to an implementation of 'interface org.camunda.bpm.engine.impl.pvm.delegate.ActivityBehavior' nor 'interface org.camunda.bpm.engine.delegate.JavaDelegate'."

configuring java class like above worked?

You was misconfigured the Delegate expression. It should be the spring bean ${dummyDelegate}, and your delegate should be annotated with spring stereotypes.

Refer the docs for Delegate expression:

Corresponding java delegate should be like:

@Component("dummyDelegate")
public class DummyDelegate implements JavaDelegate {
  public void execute(DelegateExecution delegate) throws Exception {
    System.out.println("Spring Bean invoked.");
  }
}

@dscheinin upload your bpmn file and delegate class here, i will verify it.

Cool, I’m uploading it right now.
In the meantime, I’ll try your last suggestion.
Java class (as TXT due restrictions on this forum)
DummyDelegate.txt (954 Bytes)
BPMN
delegationTests.bpmn (3.1 KB)
Thanks!

Refer this example:

update the version in pom.xml and check.

1 Like

@aravindhrs thank you for your help.
Following the code snippet you recommended me worked for me!

Again, thank you very much