0 Replies Latest reply on Jul 13, 2016 2:04 AM by Solomon Mohanty

    Why a java script works fine in rhino engine in java1.6, but not in nashorn script engine in java1.8?

    Solomon Mohanty

      A java script to load java classes from a http server by a custom class loader works fine in jre1.6 with rhino engine. But same script doesn't

      work in nashorn engine in jre1.8. Exception thrown is

      java.security.AccessControlException: access denied ("java.net.SocketPermission" "" "connect,resolve"


      I tried using below URL to give all permission for java and script code to have all permissions.



      Code is similar to below lines:

      "var tmp = UcmdbServiceFactory.initSSL();" +

        "var serviceProvider = UcmdbServiceFactory.getServiceProvider(\"https\",\"\",8443); " +

        "var clientContext = serviceProvider.createClientContext(\"UCSD\"); " ;

           ScriptEngineManager m = new ScriptEngineManager();

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

        File file = new File(args[0]);


              try {


              URI uri = file.toURI();

              URL url = uri.toURL();

              engine.eval(new URLReader(url));


      If anybody has any experience with network class loaders using nashorn script engine, help here.