I am new to Camunda and running the example server on my localhost. I would like to test using a listener javascript script from an external file, but cannot figure out where to place the javascript file.
Other topics have stated that the file can be placed in the WEB-INF/classes folder, but I am receiving an error ‘Unable to find resource’.
My path is: C:\camunda server\server\apache-tomcat-9.0.12\webapps\camunda\WEB-INF\classes.
The xml is: <camunda:script scriptFormat=“javascript” resource=“classpath://JavaScriptTest.js” />.
Are my paths correct? Is it possible to simply place the scripts within the folder structure like this, or must it be included with a deployment? Is this even the correct webapp where my deployments from the modeler will execute? Thanks.
1 Like
You can place your file in the Camunda/lib folder and it should read it from there
1 Like
Thanks for the quick reply! I tried that and still no luck.
My new path: C:\camunda server\server\apache-tomcat-9.0.12\webapps\camunda\lib.
The xml remains: <camunda:script scriptFormat=“javascript” resource=“classpath://JavaScriptTest.js” />
Can you try inside of a script that is embedded into the Bpmn something like load('classpath:myScript.js')
Then call a method from that script. Just check that classpath loading is working.
I found the correct location. I placed the file within the lowest level lib folder within Tomcat:
C:\camunda server\server\apache-tomcat-9.0.12\lib
What about when using the Wildfly server?
Where can I put my external resource there?
PS: I want to use Groovy scripts.
Example:
deployment://com.my.scripts.TaskListener.groovy
Hi @Aladdin,
if you reference them with deployment:
, then you have to deploy them together with your processes.
Either in the same REST call (https://docs.camunda.org/manual/7.11/reference/rest/deployment/post-deployment/) by uploading all files or with a programmatic deployment:
processEngine.getRepositoryService()
.createDeployment()
.addInputStream("BPMNFile 1", new FileInputStream("path to bpmn file"))
.addInputStream("script 1", new FileInputStream("path to groovy script 1"))
.deploy();
All files will be stored in the database.
Hope this helps, Ingo
And if I don’t want to deploy the scripts together with my processes?
I need a central place - preferably a path/package - with all my scripts - where I need some dynamics.
I want to reference (using the external script mechanism) these scripts from within my processes/TaskListeners. So, if I modify a script, the process instance will use the most recent script.
Hi @Aladdin,
if you don’t want to reference them from a deployment, they have to be available on the classpath: https://docs.camunda.org/manual/7.11/user-guide/process-engine/scripting/#script-source
In Wildfly you have to package additional code as a module and add it to the other Wildfly modules. As they reference each other, you have to add your new module in the existing engine module.
Here is another thread discussing the details: Create "Global" Module in WildFly for Custom Library Using Java Delegate Classes
Hope this helps, Ingo
2 Likes
Hi all,
I am using the Camunda spring boot engine and I have placed my external script file “example.js” in the src/main/resources folder. Any idea what should be the resource path to be given in modeler.