[x3d-public] X3DJSAIL, fix final error in java/nashorn build

John Carlson yottzumm at gmail.com
Tue Jul 17 03:40:11 PDT 2018


Don, can you try to fix this final problem with the java/nashoirn/build.xml test.nashorn build?  Thanks!

I discovered that you can use classpath: to load JavaScripts from the classpath in Nashorn, which fixed quite a few errors
John
     [java] org.web3d.x3d.sai.X3DException: ScriptException when processing fileName ..\nashorn\examples\HelloWorldProgramOutput.Nashorn.js.intermediate.js, unable to save result: javax.script.ScriptException: TypeError: Cannot load script from classpath:../nashorn/examples/HelloWorldProgramOutput.Nashorn.js.intermediate.js in <eval> at line number 1
     [java]     at org.web3d.x3d.jsail.Core.X3DObject.toFileJavaScript(X3DObject.java:1666)
     [java]     at org.web3d.x3d.jsail.CommandLine.run(CommandLine.java:628)
     [java]     at org.web3d.x3d.jsail.CommandLine.main(CommandLine.java:163)

Here is my current patch, I think the problem is with the last difff, but I don’t know how to fix it right:

svn diff CreateX3dSceneAccessInterfaceJava.xslt
Index: CreateX3dSceneAccessInterfaceJava.xslt
===================================================================
--- CreateX3dSceneAccessInterfaceJava.xslt      (revision 27088)
+++ CreateX3dSceneAccessInterfaceJava.xslt      (working copy)
@@ -3907,9 +3907,9 @@
                                        // patches by John Carlson
                     bufferedWriter = Files.newBufferedWriter(intermediateJSFilePath, charset);
                                        String nashornFolder = "nashorn";
-                                       String tmpStr = "load('"+nashornFolder+"/jvm-npm.js');\n";
+                                       String tmpStr = "load('classpath:"+nashornFolder+"/jvm-npm.js');\n";
                                        bufferedWriter.write(tmpStr, 0, tmpStr.length());
-                                       tmpStr = "load('"+nashornFolder+"/repeatPolyfill.js');\n";
+                                       tmpStr = "load('classpath:"+nashornFolder+"/repeatPolyfill.js');\n";
                                        bufferedWriter.write(tmpStr, 0, tmpStr.length());
                                        tmpStr = "var xmldom = require('"+nashornFolder+"/node_modules/xmldom');\n";
                                        bufferedWriter.write(tmpStr, 0, tmpStr.length());
@@ -3933,9 +3933,9 @@
                                        bufferedWriter.write(tmpStr, 0, tmpStr.length());
                                        tmpStr = "var fieldTypes = require('"+nashornFolder+"/node/fieldTypes.js');\n";
                                        bufferedWriter.write(tmpStr, 0, tmpStr.length());
-                                       tmpStr = "load('"+nashornFolder+"/node/X3DJSONLD.js');\n";
+                                       tmpStr = "load('classpath:"+nashornFolder+"/node/X3DJSONLD.js');\n";
                                        bufferedWriter.write(tmpStr, 0, tmpStr.length());
-                                       tmpStr = "load('"+nashornFolder+"/node/JavaScriptSerializer.js');\n";
+                                       tmpStr = "load('classpath:"+nashornFolder+"/node/JavaScriptSerializer.js');\n";
                                        bufferedWriter.write(tmpStr, 0, tmpStr.length());
                                        tmpStr = "var child = CreateElement('X3D');\n";
                                        bufferedWriter.write(tmpStr, 0, tmpStr.length());
@@ -3963,7 +3963,7 @@
                 }
                 try {
                                        ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn");
-                                        engine.eval("load('"+intermediateJSFileName+"');");
+                                        engine.eval("load('classpath:"+intermediateJSFileName+"');");
                                        if (ConfigurationProperties.isDeleteIntermediateFiles()) // clean up when done
                                                        intermediateJSFilePath.toFile().deleteOnExit();
                                        engine.eval("print('Hello World!');");
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20180717/d2fe215a/attachment.html>


More information about the x3d-public mailing list