Expand my Community achievements bar.

SOLVED

Using Nashorn Script Engine in AEM

Avatar

Level 2

Hi All,

I am currently working on  AEM SP2 with JDK8 & trying to build a Handlebar Script Engine in AEM. For the Handlebar Compilation & processing we were loading the Nashorn Script Engine inside AEM & the Nashorn will be used to evaluate handlebars.js & other processing. I am loading the Nashorn engine as per instructions on http://www.oracle.com/technetwork/articles/java/jf14-nashorn-2126515.html with below lines of code. But the nashorn Engine is not initializing.

ScriptEngineManager engineManager = new ScriptEngineManager(); ScriptEngine engine = engineManager.getEngineByName("nashorn");

Another option which I tries was to Initialize  ScriptEngineManager via OSGi @Reference Notation. When I do that It gives me all the Registered Script Engines in AEM available @ http://localhost:4502/system/console/status-slingscripting , but again Nashorn isn't among them.

Can anyone help me how to load Nashorn Engine inside AEM or do I have to do a Custom Implementation OF Nashorn Script Engine in AEM?

Thanks

Nitin

1 Accepted Solution

Avatar

Correct answer by
Employee

From within AEM, the available ScriptEngineManager does not pick up ScriptEngines (like Nashorn) which are registered outside the OSGi framework. You will need to register Nashorn with Sling's ScriptEngineManager. Better yet would be if Nashorn was available as an OSGi bundle, in which case it could just be dropped in. This is the case, for example, with Groovy.

View solution in original post

11 Replies

Avatar

Community Advisor

Hey Nitin,

Current AEM6 runtime is Rhino and it's implementation can be found here:

org.apache.sling.scripting.javascript.RhinoJavaScriptEngine

As per my current understanding Nashorn is not supported in AEM 6, even so it's added as default engine in JDK 8.

Peter

Avatar

Correct answer by
Employee

From within AEM, the available ScriptEngineManager does not pick up ScriptEngines (like Nashorn) which are registered outside the OSGi framework. You will need to register Nashorn with Sling's ScriptEngineManager. Better yet would be if Nashorn was available as an OSGi bundle, in which case it could just be dropped in. This is the case, for example, with Groovy.

Avatar

Level 2

Thanks for your response Peter. Yes It's not yet added in the AEM's list of Script Engines. That's the reason I am trying to load it directly from JDK considering nashorn.jar is already in the classpath.

ScriptEngineManager engineManager = new ScriptEngineManager();

ScriptEngine engine = engineManager.getEngineByName("nashorn");

It looks like I will have to create a new NashornScriptEngine in AEM using nashorn.jar.

Thanks

Nitin

Avatar

Level 1

To configure your router with Arris it is necessary to finish the authentication process for the arris router first. If you require the instructions for how to conduct the login, then you will get it all here. Be sure to follow the step by guideline for arris router login here.

Login to Arris Router

Avatar

Level 1

Orbi router comes with a sophisticated and efficient router that can supply homes with best internet speed. To access the setup page for your Orbi router you will need to complete the Orbilogin. Follow this guideline on how to finish the process of logging in to Orbi quickly and easily.

Netgear Orbi AX4200 Router

Avatar

Level 1

this is nice psot thanks for sharing this ----We will provide any antivirus installation error solution you can use this support service team members and find a solution to complex issues related to antivirus.

https://garminexpress.global/
http://rand-mcnally-gps-update.com/
http://belkin-setup.com/
http://mywifi-extt.com/

Avatar

Level 1

Wavlink is made for the sole purpose of serving its users with super internet speed. If you are looking for how to install and configure your Wavlink router, use this weblink wifi.wavlink.com to initiate the process. Then continue with these simple set up steps to complete your setup. 

 

Avatar

Level 1

If you come across an error message saying- routerlogin.net not working  try to access the Netgear router login page by accessing the 192.168.1.1 IP address   Netgear Router login 

Avatar

Level 1

The Lomota is made out of cheap plastic and has a screw fitting at its back body panel. The main device is hexagonal in shape with regular information and branding “Lomota” printed on his body. 

Avatar

Level 1

This Blink mini compact plug-in smart camera has the latest 1080 HD technology. It has good video quality and the live view is also decent. If you need support and services ,visit our website .

Avatar

Level 1

A good blog and very interesting what else is the concept applied to give deep meaning, thank you very helpful
<a href=https://mytranscriptionplace.com/translation>Simultaneous and Consecutive interpretation services</a>