Update external script

Hi everyone,

I am using several Script-Tasks in my processes. I implement the logic in external files and configure the Script-Tasks with

Script Type: External Resource

It looks like this:

externalresource

I place the JavaScript-file in the following folder:

camunda_home/server/apache-tomcat-x/lib/scripts/myscript.js

When executing my processes, the engine is able to find the script and execute it correctly.

But if the script was loaded once, it doesn’t reload the script when running further instances. That means, if I change the script, rename the file, or even delete the file, the new instances still run with the code that was loaded with the first instance.
Until now I have to restart my Tomcat so that the changes are applied and the updated script-code is used.

So my question is:
How can I tell the process to always look for the newest version of the scripts instead of using an already loaded script? Are there any other things that need to be considered when working with external scripts?

Regards
Michael

1 Like

Hi @MichiDahm
I’ve a situation similar to yours, but in my case I’ve used http-connector.
I’ve tried this in implementation of ProcessEnginePlugin:
processEngineConfiguration.setEnableScriptEngineCaching(false);
But unfortunately that didn’t work.

Have you found any solution? Would you please share some hints?
Thanks in advanced.

As a quick workaround to move your forward: use the load() nashorn js command time load a file from the classpath : load(“classpath:someFolder/myscriptjs”)

2 Likes

I’ve seen your workaround in another topic, and it works.

Thanks a bunch @StephenOTT.

Edit:
When run the application in debug, it works, I mean that if I do some changes in the loaded script, and start a new process, it flows as the new script. But when packaging and deploying the app in external Tomcat 9.0, it didn’t work.
Is there any configuration I have to set in tomcat?

What did not work? It still cached?

@StephenOTT thank you for your quick reply.
Yes. it still cached.(just when the spring boot application is deployed to exteranl Tomcat server).

Hi all,
It seems that the problem in file caching in tomcat (embedded or external). Anyway, the solution was in loading the script using FileSystemResource.
f = new FileSystemResource(resourceLocation).getFile();
String ssss = new String(Files.readAllBytes(f.toPath()));
return ssss;

1 Like

thanks for sharing!