Cannot use Scripts tasks with embedded Camunda (scriptEngine is null)

Hello everyone,

I am working with a microservice that Camunda is embedded there.

The stack is Java with Spring Boot.

As you can see when I am trying to execute a script task that contains either a JavaScript or a Groovy script I get NullValueException

Can't find scripting engine for 'javascript': scriptEngine is null
org.camunda.bpm.engine.exception.NullValueException: Can't find scripting engine for 'javascript': scriptEngine is null
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_312]
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_312]
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_312]
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_312]
	at org.camunda.bpm.engine.impl.util.EnsureUtil.generateException(EnsureUtil.java:394) ~[camunda-engine-7.15.0.jar:7.15.0]
	at org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull(EnsureUtil.java:55) ~[camunda-engine-7.15.0.jar:7.15.0]
	at org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull(EnsureUtil.java:50) ~[camunda-engine-7.15.0.jar:7.15.0]
	at org.camunda.bpm.engine.impl.scripting.engine.ScriptingEngines.getGlobalScriptEngine(ScriptingEngines.java:138) ~[camunda-engine-7.15.0.jar:7.15.0]
	at org.camunda.bpm.engine.impl.scripting.engine.ScriptingEngines.getScriptEngineForLanguage(ScriptingEngines.java:112) ~[camunda-engine-7.15.0.jar:7.15.0]
	at org.camunda.bpm.engine.impl.scripting.env.ScriptingEnvironment.execute(ScriptingEnvironment.java:82) ~[camunda-engine-7.15.0.jar:7.15.0]
	at org.camunda.bpm.engine.impl.delegate.ScriptInvocation.invoke(ScriptInvocation.java:47) ~[camunda-engine-7.15.0.jar:7.15.0]

I believe I’ve read every topic regarding this issue and almost every suggested solution refers to downgrading the JDK. My JDK version is 8.

openjdk version "1.8.0_312"
OpenJDK Runtime Environment (build 1.8.0_312-8u312-b07-0ubuntu1~20.04-b07)
OpenJDK 64-Bit Server VM (build 25.312-b07, mixed mode)

Also IntelliJ has been set to 1.8 as well.

main.bpmn (2.4 KB)
subprocess.bpmn (2.3 KB)

main.bpmn contains a subprocess that it’s present on subprocess.bpmn and there the variable is being set.

Thank you.

Try adding these 2 dependencies to the pom.xml of your Spring boot project.

<dependency>
  <groupId>org.graalvm.js</groupId>
  <artifactId>js</artifactId>
  <version>21.1.0</version>
</dependency>  
<dependency>
  <groupId>org.graalvm.js</groupId>
  <artifactId>js-scriptengine</artifactId>
  <version>21.1.0</version>
</dependency>

This should help you with any Java versions > 14. The issue is that newer versions of Java deprecated the default scripting engine, so you have to manually add it to your project. If you downgrade to Java 8 then the required components are still there.

2 Likes

Sadly I cannot modify anything to the Spring Boot project because it’s not a personal project.
The issue with the Script Engine seems to happen only on my environment, that’s why I didn’t provide any information regarding the application itself.

So I am looking for some tips on what to look for in my environment.

OK, but maybe it helps you to know that the issue is this: Oracle Proposes Deprecating Java's JavaScript Engine Nashorn

Now, If it only happens in your environment:
1.- Make sure your project downloads all the dependencies required
2.- Make sure your dependency management tool builds the project properly

2 Likes

The direction you pointed out was the correct one.

I was dealing with WSL and moving projects to directories inside and out of WSL. So I cleaned everything and rebuild it.

Works great thanks alot.