Debug Custom JavaScript Index Stages

To debug a JavaScript Index stage you can:

  • Check the Fusion API server logs for errors.

  • Use the logger object for print debugging (in the Fusion log file api.log).

The JavaScript Engine Used by Fusion

The JavaScript engine used by Fusion is the Nashorn engine from Oracle. See The Nashorn Java API for details.

Upgrading to the latest Nashorn engine

The default version of the Nashorn engine used by Fusion versions 2.4.1 and earlier is the nashorn-0.1-jdk7.jar which contains many bugs that have since been fixed in the official JDK 1.8 version. In order to use the latest version of the Nashorn engine, you must:

  • Have an up-to-date version of Java 8 installed.

  • Remove the nashorn-0.1-jdk7.jar from the Fusion classpaths:


    • find . -name "nashorn-0.1-jdk7.jar" -print -exec rm -i {} \;

Creating and accessing Java types

The following information is taken from Oracle’s JavaScript programming guide section 3, Using Java From Scripts.

To create script objects that access and reference Java types from Javascript use the Java.type() function:

var ArrayList = Java.type("java.util.ArrayList");
var a = new ArrayList;