[cbjavaloader] The requested class could not be found

I’m trying to load a different version of PDFBox in my Lucee app using JavaLoader. However, I’m getting an error message, “The requested class could not be found” when trying to inject the PDFBox class in my model.

Here’s what my code looks like:

component {

    property name="pdfBox"  inject="javaloader:org.apache.pdfbox";

    function init() {
        return this;
    }

}

I can confirm that Javaloader has loaded the pdfBox jar by dumping out javaLoader.getLoadedURLs():

Does anyone have any tips on how I can inject this jar with javaloader?

Noob mistake. My problem was that I was trying to reference pdfbox itself, instead of an actual class.

The solution was to change:
property name="pdfBox" inject="javaloader:org.apache.pdfbox";
to
property name="pdfRenderer" inject="javaloader:org.apache.pdfbox.rendering.PDFRenderer";

One tip for anyone else that isn’t a Java programmer is that you can open the .jar file using any app that can open zip files and browse the contents until you find the .class file you want.