I’m implementing a custom JavaDelegate class with spring boot app.
If I include this custom class in the Camunda spring boot application then works fine.
But I want to exclude this class to the external jar file.
When I move this custom class to external jar file and include this jar to the classpath then following error occurred.
If you have any solution, please let me know.
[ Stacktrace ]
021-06-21 12:57:23.464 ERROR 1 — [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path  threw exception [Request processing failed; nested exception is org.camunda.bpm.engine.ProcessEngineException: ENGINE-09008 Exception while instantiating class ‘wf.splitter.SplitByCaseData’: ENGINE-09017 Cannot load class ‘wf.splitter.SplitByCaseData’: org/camunda/bpm/engine/delegate/JavaDelegate] with root cause
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602) ~[na:na]
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) ~[na:na]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) ~[na:na]
at java.base/java.lang.ClassLoader.defineClass1(Native Method) ~[na:na]
can you upload the model and the java class you’re trying to call?
Thank you for your quick response!
I created very simple projects in the GitHub.
FYI: “example-workflow-service/start-camunda.bat” is application start batch.
Please clone or check following repositories:
Model file is deployed “example-workflow-service/src/resouces/ExampleFlow.bpmn”
And my custom JavaDelegate is implemented “example-external-wf-tasks/src/main/java/info/s1products/ExampleTask.java”
Have you configured like above for delegate class in your model?
It should be like
Would recommend using @Component annotation over full path.
Yes I’m defined same class name in the model.
I don’t use this function, it’s very useful. I will try!
But I think this issue caused by jvm class loader, because if I include this class in the same project file then works fine. So this expression function is not affect for this issue.
Your advice is correct. This issue occurred by class loader.
I can handle external jar files with pom file modification and java command option!
Detail is next message, please see it.
I can handle custom JavaDelegate in external jar files!
Conclusion, this issue is occurred by spring boot class loader mechanism.
Usually, default spring boot application launcher is using “JarLauncher”. But this launcher can not add external classpath.
So I changed it to “PropertiesLauncher”. This launcher can be handle external classpath.
(This way is little bit tricky because you do not specify PropertiesLauncher directly in the pom.xml.)
Following is example of pom.xml for PropertiesLauncher.
And also, I added “-Dloader.path=extlibs/*” on my application command line.
Then custom delegate works perfect
I committed new pom.xml and batch file in github repositories.
Please check them if same issue occurred.
Thank you again!