Jsoup object instantiates but jsoup.parse(html) has errors

I’m migrating from Hostek to InMotion.

Lucee is running fine on InMotion except for jsoup.

The jsoup object instantiates with no problems, but jsoup.parse(html) triggers this error (see my source code below):

(class: org/jsoup/parser/HtmlTreeBuilder, method: insert signature: (Lorg/jsoup/nodes/Element;)V) Incompatible argument to function

jsoup has been fine on my Hostek server for years and I’m trying for now to stick with the same versions of everything on my new InMotion server so I’m using jsoup v1.8.3 but I’ve also tried the current release v1.17.2 which triggers different error:

class org.jsoup.parser.Token$StartTag cannot access its abstract superclass org.jsoup.parser.Token$Tag (org.jsoup.parser.Token$StartTag is in unnamed module of loader lucee.commons.io.res.util.ResourceClassLoader @78477f36; org.jsoup.parser.Token$Tag is in unnamed module of loader java.net.URLClassLoader @55d56113)

The html variable in my test script isn’t the issue because the same errors happen even if I simply call jsoup.parse('foo').

Any ideas?

Request.jsoup_path = "/opt/lucee/lib/jsoup-1.8.3.jar";
// Request.jsoup_path = "/opt/lucee/lib/jsoup-1.17.2.jar";
dump(label="Request.jsoup_path", var=Request.jsoup_path);

jsoup = CreateObject("java", "org.jsoup.Jsoup", Request.jsoup_path);
dump(jsoup);

html = '<html><body><h1>Hello, World!</h1></body></html>';
htmldoc = jsoup.parse(html);
dump(htmldoc);

I used the Lucee installer for Lucee/Tomcat/Java.

OS: AlmaLinux 8.9
Java Version: 11.0.20 (Eclipse Adoptium) 64bit
Tomcat Version: 9.0.78
Lucee Version: 5.3.9.173

I figured it out! I simply moved jsoup-1.8.3.jar from /opt/lucee/lib into /usr/share/java, which I actually had to create because Java is only installed via Lucee installer for its own internal use, not for the entire system. But I figure if I ever need Java elsewhere on the server, it’s a good centralized location.

I also figured out that jar files placed in /opt/lucee/lib are loaded by Lucee automatically, so I also had to delete other versions of jsoup that I had in there. I could have left v1.8.3, but it’s only needed in a small number of scripts accessed by relatively few users.

It’s enough to have it fixed and maybe this info will benefit someone else in the future, but I’m still curious about Lucee internals …

Via cfscript is it possible to get list of jar files that have been loaded by Lucee including their version numbers?

Is there documentation anywhere of all the various jar-containing Lucee folders and how to use each one?

Other folders:

/opt/lucee/jre/lib/
/opt/lucee/tomcat/bin/
/opt/lucee/tomcat/lib/
/opt/lucee/tomcat/lucee-server/bundles/
/opt/lucee/tomcat/webapps/ROOT/WEB-INF/lucee/context/
/opt/lucee/tomcat/webapps/ROOT/WEB-INF/lucee/lib