How to setup the Nashorn JS engine in JBoss EAP with java 17?

Solution Verified - Updated -

Issue

  • In JDK11 the Nashorn JavaScript Engine was deprecated as per JEP 335 and then removed in JDK15 as per JEP 372, so the JavaScript Engine is no longer available in the JDK as per JDK15+. Since Nashorn is no longer part of the JDK, Nashorn 15.6 can be used so the dependency "org.openjdk.nashorn:nashorn-core:15.6" was added to the war-application on JBoss EAP 7.4.12 running with java-17-openjdk-17.0.2.0.8-1.win.x86_64 on windows. Following error occurs when initializing Nashorn:
ERROR 14:29:50,808 (default task-9) (DefaultRequestExceptionHandler.java:renderException:259) -Processing of request failed with uncaught exception: java.lang.NoClassDefFoundError: jdk/dynalink/RelinkableCallSite: java.lang.NoClassDefFoundError: jdk/dynalink/RelinkableCallSite
    at org.openjdk.nashorn//org.openjdk.nashorn.internal.runtime.Context.<init>(Context.java:655)
    at org.openjdk.nashorn//org.openjdk.nashorn.internal.runtime.Context.<init>(Context.java:585)
    at org.openjdk.nashorn//org.openjdk.nashorn.api.scripting.NashornScriptEngine.lambda$new$0(NashornScriptEngine.java:126)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at org.openjdk.nashorn//org.openjdk.nashorn.api.scripting.NashornScriptEngine.<init>(NashornScriptEngine.java:124)
  • How to make the jdk.dynalink module visible to this mentioned JBoss Service Module Loader?

Environment

  • Red Hat JBoss Enterprise Application Platform (JBoss EAP)
    • 7.4
    • OpenJDK 17
    • Nashorn 15.6

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content