leaningtech / cheerpj-meta

Run Java 8 applications, libraries, applets, Java Web Start, and Oracle Forms on the web without legacy plugins.
https://labs.leaningtech.com/cheerpj
459 stars 21 forks source link

Debugging JAR loading issues #135

Closed jkmartindale closed 2 years ago

jkmartindale commented 2 years ago

Is there any guidance for debugging JAR loading issues? I've reviewed the tutorial and ensured that the JAR file is accessible. Calling cheerpjRunJar on the .jar path as the tutorial suggested led to 404s from the http.server logs and a "Error: An unexpected error occurred while trying to open file" message from CheerpJ in the console. Changing the path to include .js removed the 404s but resulted in the same error.

I'm at wit's end trying to figure this out. The JAR is a console application so I didn't expect too much trouble.

alexp-sssup commented 2 years ago

Please see the suggestions here: https://docs.leaningtech.com/cheerpj/Frequently-Asked-Questions#my-application-compiled-with-cheerpj-does-not-work-and-i-just-see-the-cheerpj-runtime-ready-on-the-top-of-the-screen-whats-going-on

The most common source of error is: /app/ refers to the root of the HTTP server, it's not relative to the current page. This is documented here: https://docs.leaningtech.com/cheerpj/File-System-support

You can always use the network tab to see what is the JAR URL that CheerpJ is trying to use.

jkmartindale commented 2 years ago

Thanks for the response. The Network tab shows nothing but 200s and the request for the converted JAR seems successful, both from browser logs and http.server logs. However, the error message remains unchanged. What are my next steps?

alexp-sssup commented 2 years ago

Can you upload your current state to a publicly accessible location so that we can take a look?

jkmartindale commented 2 years ago

Here's a zip archive of my CheerpJ working directory https://files.jkmartindale.dev/cheerpj-ysoserial.zip

alexp-sssup commented 2 years ago

There was a mistake in my previous reply. There is indeed an obvious typo, but it's a different one:

cheerpjRunJar("/app/ysoserial.jar.js", "CommonsCollections1", "calc.exe");

The first argument should be the JAR file. Not the JAR.JS file.

See here for examples: https://docs.leaningtech.com/cheerpj/Runtime-API

Also, I am not sure if CommonsCollections1 is supposed to be a class name, but using cheerpjRunJar it will be interpreted as an argument, with "calc.exe" being the second argument.

jkmartindale commented 2 years ago

Ah my bad. I misinterpreted the tutorial and assumed that the original JAR did not need to be served and lack of .js at the end of the example path was a mistake. Correcting the load path and serving the original JAR as well fixed loading. Thanks!