How do you add/start a bundle

What’s the correct way to add/start a bundle?

I’m trying to convert PDFs to Images so I’m using the java library org.apache.pdfbox.pdmodel.PDDocument which is included as part of the “PDF Extension” that is installed on my lucee 5 instance.

However when I try to access it, I get

cannot load class through its string name, because no definition for the class with the specified name [org.apache.pdfbox.pdmodel.PDDocument] … java.lang.ClassNotFoundException:org.apache.pdfbox.pdmodel

However, if I add a throwaway call to the pdf tag, something like:

pdf action="getInfo" source=pdfFile name="throwAway";

Then call my code, my code now works.

Looking at the application log, the pdf call has kicked off a chain of add and start bundles.

So, how can I do this or ensure something has done this before my code executes?

My initial thought is to put a dummy call in the healthcheck that’s run on server start to ensure it’s there, but is that the best solution?

Kind regards

I think you just need to specify the bundle name as the third argument when instantiating the class.

pdfReader = CreateObject( "java", "org.apache.pdfbox.pdmodel.PDDocument", "pdf.extension" );

1 Like

Yup, that’s fixed the issue.

Thanks