I am trying to load an external groovy script in my BPMN and I can’t find any way to do this. It is important to mention I am running a Camunda engine from a .jar file so I can’t put my groovy script to META-INF.
My setup:
Run Camunda engine from compiled .jar sudo java -cp "home/e/h2/bin/h2-1.4.199.jar" -jar -Dspring.profiles.active="local" camunda-compiled.jar
Put together a BPMN file with a Script task using External script script1.groovy
Deploy BPMN to the started engine
After starting an instance of the process I get an error when the process comes to the Script tast defined in step number 2 saying it can’t load script1.groovy.
I have tried to put my script1.groovy to the same directory as my .bpmn process. Also I tried to specify an extra classpath sudo java -cp "/home/e/groovy_scripts/script1.groovy;/home/e/h2/bin/h2-1.4.199.jar" -jar -Dspring.profiles.active="local" camunda-compiled.jar. Nothing has worked.
I have tried using load function as one forum topic suggested, but I had no success using it. (I put load(‘classpath:script1.groovy’) as the script task inline script as well as external task…)
Is there a way to load an external script, please?
Hello erhan
You can refer you extenal script as classpath resource. Just add configure ScriptTask with “Script Type => External Resource” and specify Resource with prefix “classpath://”.
Hi, Roman,
this approach does not work for me. Camunda engine does not find the script Caused by: org.camunda.bpm.engine.exception.NotFoundException: ENGINE-09024 Unable to find resource at path classpath://script1.groovy .
I guess this way would work in case I would put the groovy script inside Camunda java project. But I execute Camunda engine from a .jar file and then only deploy a .bpmn to it.
At the command line should be classpath for the folder where do you have your scripts (not the script). Try this: java -cp "/home/e/groovy_scripts/;home/e/h2/bin/h2-1.4.199.jar" …
I think, deployed scripts are referenced with prefix deployment://. See ResourceUtil.java