<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
.MsoChpDefault
{mso-style-type:export-only;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style></head><body lang=EN-US link=blue vlink="#954F72"><div class=WordSection1><p class=MsoNormal>Under OpenJDK 8 on Ubuntu under windows, the jjs command is:</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>$ jjs -J-Djava.class.path=jars/X3DJSAIL.3.3.full.jar:classes nashorn/examples/Json.js</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>And the cd command is:</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>$ cd /mnt/c/x3d-code/www.web3d.org/x3d/stylesheets/java/</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Sent from <a href="https://go.microsoft.com/fwlink/?LinkId=550986">Mail</a> for Windows 10</p><p class=MsoNormal><o:p> </o:p></p><div style='mso-element:para-border-div;border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal style='border:none;padding:0in'><b>From: </b><a href="mailto:yottzumm@gmail.com">John Carlson</a><br><b>Sent: </b>Wednesday, June 6, 2018 5:37 PM<br><b>To: </b><a href="mailto:brutzman@nps.edu">Don Brutzman</a><br><b>Cc: </b><a href="mailto:x3d-public@web3d.org">x3d-public@web3d.org</a><br><b>Subject: </b>RE: X3DJSAIL, X3dToJava.xslt and DOM X3DLoaderObjecttesting:anotherClassCastException</p></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Try stepping through with these commands at command prompt or similar (you’ll have to use diff and cp from Ubuntu, now available on Windows or similar commands under DOS)<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>$ cd /c/x3d-code/www.web3d.org/x3d/stylesheets/java/<o:p></o:p></p><p class=MsoNormal>$ javac -cp lib/javax.json-api-1.0.jar src/net/coderextreme/X3DJSONLD.java<o:p></o:p></p><p class=MsoNormal>$ cp src/net/coderextreme/X3DJSONLD.class classes/net/coderextreme/<o:p></o:p></p><p class=MsoNormal>$ jjs -cp "jars/X3DJSAIL.3.3.full.jar;classes" nashorn/examples/Json.js # you may have to use the Java 8 way of specifying the classpath. See build.xml<o:p></o:p></p><p class=MsoNormal>$ diff -w nashorn/examples/HelloWorldProgramOutput.Java.x3d nashorn/examples/Json.x3d<o:p></o:p></p><p class=MsoNormal>32a33,35<o:p></o:p></p><p class=MsoNormal>> <meta name='translated' content='27 May 2018'/><o:p></o:p></p><p class=MsoNormal>> <meta name='generator' content='X3dToJson.xslt, http://www.web3d.org/x3d/stylesheets/X3dToJson.html'/><o:p></o:p></p><p class=MsoNormal>> <meta name='reference' content='X3D JSON encoding: http://www.web3d.org/wiki/index.php/X3D_JSON_Encoding'/><o:p></o:p></p><p class=MsoNormal>35,38c38<o:p></o:p></p><p class=MsoNormal>< <ViewpointGroup description='Available viewpoints'><o:p></o:p></p><p class=MsoNormal>< <Viewpoint DEF='DefaultView' description='Hello X3DJSAIL'/><o:p></o:p></p><p class=MsoNormal>< <Viewpoint DEF='TopDownView' description='top-down view from above' orientation='1 0 0 -1.570796' position='0 100 0'/><o:p></o:p></p><p class=MsoNormal>< </ViewpointGroup><o:p></o:p></p><p class=MsoNormal>---<o:p></o:p></p><p class=MsoNormal>> <ViewpointGroup description='Available viewpoints'/><o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>You will see the missing Viewpoint’s (children of ViewpointGroup) as above. Also jjs will generate significant output.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I can’t connect through svn, so I may be out of date.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>John<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Sent from <a href="https://go.microsoft.com/fwlink/?LinkId=550986">Mail</a> for Windows 10<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b>From: </b><a href="mailto:brutzman@nps.edu">Don Brutzman</a><br><b>Sent: </b>Wednesday, June 6, 2018 9:41 AM<br><b>To: </b><a href="mailto:yottzumm@gmail.com">John Carlson</a><br><b>Cc: </b><a href="mailto:x3d-public@web3d.org">x3d-public@web3d.org</a><br><b>Subject: </b>Re: X3DJSAIL, X3dToJava.xslt and DOM X3DLoaderObject testing:anotherClassCastException<o:p></o:p></p></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>1. Hi John, finally getting back to this one.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>On 4/30/2018 3:15 PM, John Carlson wrote:<o:p></o:p></p><p class=MsoNormal>> Previously reported problem, now assigned to the X3DLoaderObject, I believe.<o:p></o:p></p><p class=MsoNormal>> <o:p></o:p></p><p class=MsoNormal>> No Viewpoint children in X3D or JSON output.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Not sure what that means? Viewpoint node typically does not have any children, except perhaps for a Metadata* node or an IS/connect.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>> Is a problem with X3DLoaderObject, looks like another class cast exception. X3DJSONLD was eliminated from the problem by printing out the DOM object, and verifying the Viewpoint objects were there. See x3d-code/www.web3d.org/x3d/stylesheets/java/nashorn/examples/Quotes.js.<o:p></o:p></p><p class=MsoNormal>> <o:p></o:p></p><p class=MsoNormal>> Can be regenerated by running `ant test.nashorn` in x3d-code/www.web3d.org/x3d/stylesheets/java<o:p></o:p></p><p class=MsoNormal>> <o:p></o:p></p><p class=MsoNormal>> See output in nashorn/examples/Json.{json,x3d}<o:p></o:p></p><p class=MsoNormal>> <o:p></o:p></p><p class=MsoNormal>> John<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>OK have recently updated to Java JDK 1.8.0_172 and adjusted PATH to confirm jjs is running OK.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Have also synchronized X3DJSAIL sudirectory nashorn/ and contents with subversion.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I get the following outputs when running test.nashorn build target:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>============================================================<o:p></o:p></p><p class=MsoNormal>ant -f E:\\x3d-code\\www.web3d.org\\x3d\\stylesheets\\java test.nashorn<o:p></o:p></p><p class=MsoNormal>test.nashorn:<o:p></o:p></p><p class=MsoNormal>===========================================<o:p></o:p></p><p class=MsoNormal>ant nashorn/build.xml test.nashorn<o:p></o:p></p><p class=MsoNormal>X3D Nashorn SAI Library.test.nashorn:<o:p></o:p></p><p class=MsoNormal>Compile:<o:p></o:p></p><p class=MsoNormal>Compiling 1 source file to E:\x3d-code\www.web3d.org\x3d\stylesheets\java\classes<o:p></o:p></p><p class=MsoNormal>Compiling 1 source file to E:\x3d-code\www.web3d.org\x3d\stylesheets\java\classes<o:p></o:p></p><p class=MsoNormal>Copy:<o:p></o:p></p><p class=MsoNormal>Copying 1 file to E:\x3d-code\www.web3d.org\x3d\stylesheets\java\nashorn\examples<o:p></o:p></p><p class=MsoNormal>Copying E:\x3d-code\www.web3d.org\x3d\stylesheets\java\examples\HelloWorldProgramOutput.x3d to E:\x3d-code\www.web3d.org\x3d\stylesheets\java\nashorn\examples\HelloWorldProgramOutput.x3d<o:p></o:p></p><p class=MsoNormal>Copying 1 file to E:\x3d-code\www.web3d.org\x3d\stylesheets\java\nashorn\examples<o:p></o:p></p><p class=MsoNormal>Copying E:\x3d-code\www.web3d.org\x3d\stylesheets\java\examples\HelloWorldProgramOutput.json to E:\x3d-code\www.web3d.org\x3d\stylesheets\java\nashorn\examples\HelloWorldProgramOutput.json<o:p></o:p></p><p class=MsoNormal>Run:<o:p></o:p></p><p class=MsoNormal>parameter: source file HelloWorldProgramOutput.x3d filesize 20956 bytes, parsed using Document Object Model (DOM) X3DLoader<o:p></o:p></p><p class=MsoNormal>parameter: "-tojs" for conversion to X3DJSONLD JavaScript source<o:p></o:p></p><p class=MsoNormal>parameter: "-toFile" "nashorn/examples/HelloWorldProgramOutput.Nashorn.js" for result file name root nashorn/examples/HelloWorldProgramOutput.Nashorn<o:p></o:p></p><p class=MsoNormal>convert to JS JavaScript:<o:p></o:p></p><p class=MsoNormal>Warning: toFileJavaScript() is overwriting prior file nashorn/examples/HelloWorldProgramOutput.Nashorn.js<o:p></o:p></p><p class=MsoNormal>Script DEF=colorTypeConversionScript contains CDATA source-code text, copied as "#sourceText" using "strings" mode<o:p></o:p></p><p class=MsoNormal>Script DEF=MaterialModulatorScript contains CDATA source-code text, copied as "#sourceText" using "strings" mode<o:p></o:p></p><p class=MsoNormal>TypeError: input.readAllBytes is not a function<o:p></o:p></p><p class=MsoNormal>Error: Cannot read file [E:\x3d-code\www.web3d.org\x3d\stylesheets\java\nashorn\node_modules\xmldom\package.json]:<o:p></o:p></p><p class=MsoNormal>[Error] TODO problem handling local exception within CommandLine, exiting<o:p></o:p></p><p class=MsoNormal>org.web3d.x3d.sai.X3DException: ScriptException when processing fileName nashorn\examples\HelloWorldProgramOutput.Nashorn.js.intermediate.js, unable to save result: javax.script.ScriptException: Error: Cannot load JSON file in nashorn/jvm-npm.js at line number 216 at column number 8<o:p></o:p></p><p class=MsoNormal> at org.web3d.x3d.jsail.Core.X3DObject.toFileJavaScript(X3DObject.java:1662)<o:p></o:p></p><p class=MsoNormal> at org.web3d.x3d.jsail.CommandLine.run(CommandLine.java:628)<o:p></o:p></p><p class=MsoNormal> at org.web3d.x3d.jsail.CommandLine.main(CommandLine.java:163)<o:p></o:p></p><p class=MsoNormal>parameter: source file HelloWorldProgramOutput.x3d filesize 20956 bytes, parsed using Document Object Model (DOM) X3DLoader<o:p></o:p></p><p class=MsoNormal>parameter: "-toJSON" for conversion to JSON encoding<o:p></o:p></p><p class=MsoNormal>parameter: "-toFile" "nashorn/examples/HelloWorldProgramOutput.Java.json" for result file name root nashorn/examples/HelloWorldProgramOutput.Java<o:p></o:p></p><p class=MsoNormal>convert to JSON:<o:p></o:p></p><p class=MsoNormal>Warning: toFileStylesheetConversion(X3dToJson.xslt) is overwriting prior file nashorn/examples/HelloWorldProgramOutput.Java.json<o:p></o:p></p><p class=MsoNormal>Script DEF=colorTypeConversionScript contains CDATA source-code text, copied as "#sourceText" using "strings" mode<o:p></o:p></p><p class=MsoNormal>Script DEF=MaterialModulatorScript contains CDATA source-code text, copied as "#sourceText" using "strings" mode<o:p></o:p></p><p class=MsoNormal>file conversion successful: HelloWorldProgramOutput.Java.json (39749 bytes)<o:p></o:p></p><p class=MsoNormal>parameter: source file HelloWorldProgramOutput.x3d filesize 20956 bytes, parsed using Document Object Model (DOM) X3DLoader<o:p></o:p></p><p class=MsoNormal>parameter: "-toX3D" for conversion to X3D encoding<o:p></o:p></p><p class=MsoNormal>parameter: "-toFile" "nashorn/examples/HelloWorldProgramOutput.Java.x3d" for result file name root nashorn/examples/HelloWorldProgramOutput.Java<o:p></o:p></p><p class=MsoNormal>convert to X3D:<o:p></o:p></p><p class=MsoNormal>Warning: toFileX3D() is overwriting prior file nashorn/examples/HelloWorldProgramOutput.Java.x3d<o:p></o:p></p><p class=MsoNormal>file conversion successful: HelloWorldProgramOutput.Java.x3d (20956 bytes)<o:p></o:p></p><p class=MsoNormal>===========================================<o:p></o:p></p><p class=MsoNormal>============================================================<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>As you can see, the exception is in nashorn/jvm-npm.js:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal> TypeError: input.readAllBytes is not a function<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Header in that file indicates that you have modified it.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Specific javascript code block of interest:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal> function readFile (filename, core) {<o:p></o:p></p><p class=MsoNormal> var input;<o:p></o:p></p><p class=MsoNormal> try {<o:p></o:p></p><p class=MsoNormal> if (core) {<o:p></o:p></p><p class=MsoNormal> var classloader = java.lang.Thread.currentThread().getContextClassLoader();<o:p></o:p></p><p class=MsoNormal> input = classloader.getResourceAsStream(filename);<o:p></o:p></p><p class=MsoNormal> } else {<o:p></o:p></p><p class=MsoNormal> input = new java.io.FileInputStream(filename);<o:p></o:p></p><p class=MsoNormal> }<o:p></o:p></p><p class=MsoNormal> return new java.lang.String(input.readAllBytes());<o:p></o:p></p><p class=MsoNormal> } catch (e) {<o:p></o:p></p><p class=MsoNormal> System.err.println(e);<o:p></o:p></p><p class=MsoNormal> throw new ModuleError('Cannot read file [' + filename + ']: ', 'IO_ERROR', e);<o:p></o:p></p><p class=MsoNormal> }<o:p></o:p></p><p class=MsoNormal> }<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>JDK 8 Javadoc for java.io.FileInputStream does not provide a "readAllBytes()" method. (Nor does JDK 1.9; however I am currently holding at 1.8 to stay compatible with Netbeans 8.)<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal> https://docs.oracle.com/javase/8/docs/api/java/io/FileInputStream.html<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>So it looks like you need another method.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>A search for "java.io.FileInputStream readAllBytes" provides a number of hits. For example:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal> File to byte[] in Java<o:p></o:p></p><p class=MsoNormal> https://stackoverflow.com/questions/858980/file-to-byte-in-java<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>2. Continuing with your prior error console also appears fruitful:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>> [exec] [X3DLoaderObject error] Incorrectly handled object construction, current elementObject=ViewpointGroup (ViewpointGroup), child=Viewpoint, java.lang.ClassCastException: org.web3d.x3d.jsail.Navigation.ViewpointGroupObject cannot be cast to org.web3d.x3d.sai.Grouping.X3DGroupingNode<o:p></o:p></p><p class=MsoNormal>> <o:p></o:p></p><p class=MsoNormal>> [exec] java.lang.ClassCastException: org.web3d.x3d.jsail.Navigation.ViewpointGroupObject cannot be cast to org.web3d.x3d.sai.Grouping.X3DGroupingNode<o:p></o:p></p><p class=MsoNormal>> <o:p></o:p></p><p class=MsoNormal>> [exec] at org.web3d.x3d.jsail.X3DLoaderObject.toX3dObjectTree(X3DLoaderObject.java:1146)<o:p></o:p></p><p class=MsoNormal>> <o:p></o:p></p><p class=MsoNormal>> [exec] at org.web3d.x3d.jsail.X3DLoaderObject.toX3dObjectTree(X3DLoaderObject.java:542)<o:p></o:p></p><p class=MsoNormal>> <o:p></o:p></p><p class=MsoNormal>> [exec] at org.web3d.x3d.jsail.X3DLoaderObject.toX3dObjectTree(X3DLoaderObject.java:542)<o:p></o:p></p><p class=MsoNormal>> <o:p></o:p></p><p class=MsoNormal>> [exec] at org.web3d.x3d.jsail.X3DLoaderObject.toX3dObjectTree(X3DLoaderObject.java:430)<o:p></o:p></p><p class=MsoNormal>> <o:p></o:p></p><p class=MsoNormal>> [exec] at org.web3d.x3d.jsail.X3DLoaderObject.toX3dObjectTree(X3DLoaderObject.java:399)<o:p></o:p></p><p class=MsoNormal>> <o:p></o:p></p><p class=MsoNormal>> [exec] at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$372$Json$cu1$restOf.:program(nashorn/examples/Json.js:15)<o:p></o:p></p><p class=MsoNormal>> <o:p></o:p></p><p class=MsoNormal>> [exec] at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:655)<o:p></o:p></p><p class=MsoNormal>> <o:p></o:p></p><p class=MsoNormal>> [exec] at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:513)<o:p></o:p></p><p class=MsoNormal>> <o:p></o:p></p><p class=MsoNormal>> [exec] at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:527)<o:p></o:p></p><p class=MsoNormal>> <o:p></o:p></p><p class=MsoNormal>> [exec] at jdk.scripting.nashorn/jdk.nashorn.tools.Shell.apply(Shell.java:519)<o:p></o:p></p><p class=MsoNormal>> <o:p></o:p></p><p class=MsoNormal>> [exec] at jdk.scripting.nashorn/jdk.nashorn.tools.Shell.runScripts(Shell.java:448)<o:p></o:p></p><p class=MsoNormal>> <o:p></o:p></p><p class=MsoNormal>> [exec] at jdk.scripting.nashorn/jdk.nashorn.tools.Shell.run(Shell.java:186)<o:p></o:p></p><p class=MsoNormal>> <o:p></o:p></p><p class=MsoNormal>> [exec] at jdk.scripting.nashorn.shell/jdk.nashorn.tools.jjs.Main.main(Main.java:104)<o:p></o:p></p><p class=MsoNormal>> <o:p></o:p></p><p class=MsoNormal>> [exec] at jdk.scripting.nashorn.shell/jdk.nashorn.tools.jjs.Main.main(Main.java:80)<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Looks like it was trying to treat ViewpointGroup like a X3DGroupingNode - but it is not. ViewpointGroup is not a X3DGroupingNode node, and can only contain a Metadata* node, Viewpoint/OrthoViewpoint/GeoViewpoint and other ViewpointGroup nodes.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>This might have been fixed already as part of the many DOM loader improvements performed; not seeing that error in my console. Worth retesting if you can address the readAllBytes issue.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I've added a warning to X3D tooltips to clarify that.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Hope next round of improvement/testing can sort this one out fully.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>all the best, Don<o:p></o:p></p><p class=MsoNormal>-- <o:p></o:p></p><p class=MsoNormal>Don Brutzman Naval Postgraduate School, Code USW/Br brutzman@nps.edu<o:p></o:p></p><p class=MsoNormal>Watkins 270, MOVES Institute, Monterey CA 93943-5000 USA +1.831.656.2149<o:p></o:p></p><p class=MsoNormal>X3D graphics, virtual worlds, navy robotics http://faculty.nps.edu/brutzman<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>