Cannot run a JavaScript code in a Script Task

Hi,

I’m testing the trial version of the enterprise subscription of Flowable (v3.10.3), and I’m facing issues using the Script Task within a process.
I selected “JavaScript” for the Script format, and tried to run a simple script ( var test =1; ), but an error keeps occurring when I run the process on flowable work.

imagem flowable

I get this error: " Can’t find scripting engine for ‘javascript’ "

Can anyone please help? :slightly_frowning_face:

Thank you in advance.

This could be related to the java version that you are using.
I think Nashorn (the javascript engine in java) has been deprecated in later versions.
https://openjdk.java.net/jeps/335

1 Like

Thank you @maudrid
I was able to solve my issue with your help. :grinning:

hello , I’m new at coding
I’m soo confused about these codes, I’m just put some wrong codes and it’s not working well , can you give me any tips for it

Same issue.
.

i got same issue. and i don’t know how to solve this

i don’t know how to solve this..

Hey everyone,

For everyone that does not understand how to solve this and why the problem is there. Starting from Java 15 the Javascript Nashorn engine has been removed from the JDK JEP 372: Remove the Nashorn JavaScript Engine.

If you want to keep using Javascript you will need to manually add Maven Central Repository Search.

Cheers,
Filip

Not sure what dependencies I have to add in order for script task to work in Java 17. I added

implementation 'org.openjdk.nashorn:nashorn-core:15.4'

to my build.gradle file, but script task is still not working. My script task is very simple like this

execution.setVariable(“errorStatus”, “timeout”);

This script task worked fine in Java 11.

So I suspect additional dependencies are missing in addition to nashorn-core

Well, I rolled back to Java 11, it still fails. This was working last time I tested, and my script task has not changed, but apparently something has changed. The only thing I changed was to upgrade to java 17, at least that is what I thought. I do not see any errors in the log, so this becomes a black box to me. Is that a way to see what errors in my script task?

It turns out there are two issues here.

One is that the String in the script has to be in single quote even though the JavaScript standard allows either single or double quotes.

The second issue is that the script task does not seem to execute if it is right after a boundary timeout event. I asked the second issue here Script task does not execute after boundary timeout event.