mjclemente/pdfbox.cfc

PDFBox JAR doesn't appear to work if used in ColdFusion Class Path (other than \lib)

JamoCA opened this issue · 2 comments

I had the provided JAR files in the java class path (ColdFusion 2016) and encountering the following error in the application log file. (There's no on-screen error message.)

pdfreader = createobject("java", "org.apache.pdfbox.pdmodel.PDDocument");

Application Log Entry: could not initialize class org.apache.pdfbox.pdmodel.PDDocument

After further testing using CommandBox, I discovered that it would work if the JAR files were copied to the cfusion\lib sub-directory. I've been testing ~30 other JAR files and haven't encountered this before.

So, right now this seems to be a case of the "it works for me's".

I have a local CommandBox ColdFusion 2016 example working without issue.

I put together an example of it working with Adobe ColdFusion 2016 here: https://github.com/mjclemente/pdfbox-acf-2016-error-repro

It's a really basic repro - just an app.cfc, index, the jars, and pdfbox.cfc. It runs without encountering an error with the jars.

Can you see if this is working for you? That might help us narrow down the problem.

I figured out what the actual problem is. Isolating the CF server to limit which JARs were being used help prove to me that the problem was somewhere else.

I'm using an internally forked version of Address-Cleaner. It uses JGeocoder which was last updated in 2008. JGeocoder & PDFBox both include the Apache Commons Logging dependency. JGeocoder uses an older implementation, so I removed it from the JAR and tested to determine if address parsing still works. Both libs work now. (I'm not even sure if the address parsing feature of the JGeocoder library uses logging.)

I identified this by opening that JARs that I use to identify any that had a matching "org.apache" path and added them to your demo and restarted services until I could determine which one was causing the problems.