2 years ago
#54587
arcy
How can I debug my specific version of an open-source lib when there's a maven dependency for a previous version of that lib
I have a Java application for which I'm using PDFBox; the latest stable release of PDFBox is 2.0.25. I want to step through PDFBox code after my project calls it.
I have downloaded the PDFBox source, imported it as a Maven project into an eclipse workspace, and put that project on the build path for the application project. I removed the PDFBox dependency from the pom.xml for my application, and did Maven update and clean rebuild for things.
However, another part of my application uses POI, and it also depends on PDFBox, specifically 2.0.24. So the PDFBox 2.0.24 jar is in the 'referenced libraries' for the application, and I've verified that sometimes, when a PDFBox reference is made, it uses the 2.0.24 from the referenced libraries instead of my local 2.0.25 library.
Obviously in strict classpath terms this is problematic -- a classloader will run down the list of available full pathnames until it finds one, and it isn't evaluating library versions. I know this can theoretically be done, on a runtime level, with classloaders, but don't know how to apply that in my situation. How can this get resolved correctly in the general case? The general case wouldn't have to be a debugging situation, it could be 2 (or more) libraries attempting to use different versions of a common library just to get their work done.
In my current situation, I've tried putting a PDFBox dependency before the POI dependency in the dependency list in the pom.xml. I don't know any other way to influence which jar the runtime might use. Is there some way to specify that the POI code use a different classloader or something?
java
maven
apache-poi
classpath
pdfbox
0 Answers
Your Answer