2 Replies Latest reply on Apr 3, 2014 7:09 PM by Tomaz Cerar

    Wildfly Scripting Engine (Rhino vs Nashorn)

    Brandon Lederer Newbie

      I have an application working well on Glassfish.   I am working on switching to Wildfly.

       

      I did not change my JDK version, so still running JDK 7.   When I run my application, and the method instantiates javax.script.ScriptEngineManager, things start to go wrong.   I get errors about it not being able to find Nashorn. 

      ERROR [stderr] (default task-13) ScriptEngineManager providers.next(): javax.script.ScriptEngineFactory: Provider jdk.nashorn.api.scripting.NashornScriptEngineFactory not found

      "Whats Nashorn?" was my first reaction.   After googling that, I found out that it was the Replacement for the RHINO engine which is used heavily in the application, via javax.script.ScriptEngineManager.

       

      After much googling, and not finding much, my last ditch effort was to install JDK 8.

       

      I installed JDK 8 and now it tells me it can't find RhinoEngine!!!

      ERROR [stderr] (default task-10) ScriptEngineManager providers.next(): javax.script.ScriptEngineFactory: Provider com.sun.script.javascript.RhinoScriptEngineFactory not found.

       

      Any help would be MUCH appreciated.  I'm in circles... literally.

        • 1. Re: Wildfly Scripting Engine (Rhino vs Nashorn)
          Tomaz Cerar Master

          hmm, we are probably missing few paths in our sun.jdk module to make this work properly.

           

          add open WILDFLY_HOME\modules\system\layers\base\sun\jdk\main\module.xml

           

          missing paths.

           

          other thing you can do is open

          WILDFLY_HOME\modules\system\layers\base\sun\jdk\main\service-loader-resources\META-INF\services\javax.script.ScriptEngineFactory

          and remove the one that gives you problems.

          • 2. Re: Wildfly Scripting Engine (Rhino vs Nashorn)
            Tomaz Cerar Master

            Also looking trough the code/docs of ScriptEngineManager, that error message is only informative nature.

            You still get back one engine, and that is rhino or nashorn depending on what JDK you are on.

             

            JDK should probably have better error reporting in this case or none at all.

             

             

            In any case removing entry from javax.script.ScriptEngineFactory will make that problem go away, but you will need to modify every time you switch JDK.

             

            --

            tomaz