Closed ianopolous closed 8 years ago
This is a reminder to me to have better error messages during JVM bootup...
The JVM loads the thread class first to mock a Thread
object to bootstrap the JVM. It is failing to load the file, which means it cannot find java.lang.Thread
on the classpath.
And it cannot find java.lang.Thread
because the filesystem has an issue; /sys/vendor/java_home/lib/rt.jar
exists in the index, but the filesystem cannot fetch it:
BrowserFS.BFSRequire('fs').readFileSync('/sys/vendor/java_home/lib/rt.jar')
xhr.ts:164 GET http://localhost:8080/doppio/vendor/java_home/lib/rt.jar 404 (Not Found)i @ xhr.ts:164b._requestFileSync @ XmlHttpRequest.ts:101b.openSync @ XmlHttpRequest.ts:267b.readFileSync @ XmlHttpRequest.ts:334b @ MountableFileSystem.ts:300a.readFileSync @ FS.ts:474function.e.(anonymous function).f.(anonymous function) @ node_fs.ts:19(anonymous function) @ VM872:1InjectedScript._evaluateOn @ (program):145InjectedScript._evaluateAndWrap @ (program):137InjectedScript.evaluate @ (program):118
MountableFileSystem.ts:303 Uncaught f {syscall: "", errno: 404, code: undefined, path: null, stack: "Error↵ at new f (http://localhost:8080/doppio/b…/browserfs.min.js:7:8011)↵ at <anonymous>:1:28"…}
It's typing to load http://localhost:8080/doppio/vendor/java_home/lib/rt.jar
instead of http://localhost:8080/doppio/java_home/lib/rt.jar
.
But the JVM isn't even trying to load that file, because the boot classpath is set to /sys/java_home/classes
.
To fix these issues:
listings.json
by running the XmlHttpRequest
file system's indexer in the doppio
folder.Doppio.VM.JVM.getDefaultOptions(doppioHomePath)
(e.g. Doppio.VM.JVM.getDefaultOptions('/sys')
) to construct the options to the JVM, extended with the classpath
that you want for your programs.That should fix the issue.
If I run the XHRIndexer in the doppio directory it outputs something with all values null. e.g. {"browserfs.min.js":null,"browserfs.min.js.map":null...
While weird, that's actually intentional. The XHRFS
uses the JSON object directly as its index, with stats stored in each property, so storing it this way on disk prevents XHRFS
from having to transform it at runtime. This was a huge performance gain when DoppioJVM did not support JAR files, and had an index with every individual class
file in the Java Class Library!
Ah, I see. It is still failing to load Thread though with both those changes. The latest is at: https://github.com/ianopolous/DoppioDemo
Have I missed something else?
Yes; it looks like the default options expect java_home
to be in a vendor
directory. Move java_home
into vendor
, regenerate listings
, and it should work.
That fixed it! Thank you!
I've updated the getting started guide, and added an example application that can be built in a single command.
I'm trying to get doppio working in a browser. At the moment it throws an exception trying to load the java.lang.Thread class
Cannot read property 'throwNewException' of null - on line 340 of ClassLoader.ts
The webroot I'm using is at https://github.com/ianopolous/DoppioDemo