daltec
daltec

Reputation: 547

Problems loading/using jsoup in ColdBox/Lucee

there are many posts on issues similar to mine, but none of them has helped. Not sure what I am doing wrong. I am trying to load the jsoup jar using this.applicationSettings, and I keep getting an error. Specifically:

Application.cfc:

this.javaSettings = { 
    loadPaths = [ ".\lib" ], 
    loadColdFusionClassPath = true, 
    reloadOnChange= false 
};

Yes, jsoup-1.11.2.jar is in \lib for that application. I tried \lib\ too; no joy.

But every time I try to use

myJsoup = createObject("java", "org.jsoup.Jsoup");

or

myJsoup = createObject("java", "org.jsoup.Jsoup").init();

I get an error,

cannot load class through its string name, because no definition for the class with the specified name [org.jsoup.Jsoup] could be found

Does not matter what function I place the init code in -- handler or model -- or if I put it in a cfscript or cfset. I can even put it in index.cfm and still get the same error. Does not matter what I restart or how many times I restart it. It is as if ColdBox and/or Lucee just refuses to acknowledge the existence of the jar file or something. What gives?

I sure would appreciate any tips! Thanks in advance!

Upvotes: 1

Views: 461

Answers (1)

Tony Junkes
Tony Junkes

Reputation: 735

I'm not sure if this is just bad documentation out in the wild, a shortcoming of my own understanding or simply a bug in ColdFusion and Lucee...

I put together a simple test and recreated what you're seeing in both engines. I originally figured there must be an issue with paths in Lucee but ACF produces the same error.

Looking at existing code I use, it seems I always populate the full path to the JAR/Class files.

I often do something like this (which works) to load everything in the /lib directory:

this.javaSettings.loadPaths = directoryList(expandPath("/lib"));

Which in turn sets the value to [ "/mypath/lib/jsoup-1.11.2.jar" ].

Upvotes: 2

Related Questions