Uploaded image for project: 'Pentaho Reporting and Pentaho Report Designer'
  1. Pentaho Reporting and Pentaho Report Designer
  2. PRD-5626

JavaScript scripting breaks with JDK 8, as scripting engine was replaced in JDK

    XMLWordPrintable

    Details

    • Story Points:
      0
    • Notice:
      When an issue is open, the "Fix Version/s" field conveys a target, not necessarily a commitment. When an issue is closed, the "Fix Version/s" field conveys the version that the issue was fixed in.

      Description

      We are using Pentaho Report Designer to generate complex reports and we rely a lot on post processing the query results with JavaScript, but running PRD with java 8 breaks the reports because with the newly JavaScript engine (nashorn) global variables defined in Global Scripting are not visible in Query Scripting.

      I think the problem is in DataFactoryScriptingSupport class:

      if ( globalContext != null ) {
              final Bindings bindings = globalContext.getBindings( ScriptContext.ENGINE_SCOPE );
              this.context.getBindings( ScriptContext.ENGINE_SCOPE ).putAll( bindings );
      }
      

      Since nashorn associates all global variables declared in globalContext with a nashorn global object (https://wiki.openjdk.java.net/display/Nashorn/Nashorn+jsr223+engine+notes) they will not be visible when they are added to query script context: this.context.getBindings( ScriptContext.ENGINE_SCOPE ).putAll( bindings );.

      Possible solution:

      if ( globalContext != null ) {
              final Bindings bindings = globalContext.getBindings( ScriptContext.ENGINE_SCOPE );
              // this should work since ScriptObjectMirror is implementing Bindings
              Bindings nashornGlobal = bindings.get("nashorn.global");  
              this.context.getBindings( ScriptContext.ENGINE_SCOPE ).putAll(nashornGlobal);
              this.context.getBindings( ScriptContext.ENGINE_SCOPE ).putAll(bindings);
      }
      

      This affects only the data-source scripting. All other scripting parts use the Apache BSF framework, which continues to run as normal.

        Attachments

          Activity

            People

            Assignee:
            eteixeira Emanuel Teixeira (Inactive)
            Reporter:
            tmorgner Thomas Morgner
            Votes:
            3 Vote for this issue
            Watchers:
            6 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: