Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Reusing third party library from LR core in my module
Dear All,
I need PdfBox library to process PDF files in my module. It is already the integral part of the LR portal in \tomcat-9.0.10\webapps\ROOT\WEB-INF\lib\pdfbox.jar
Can I somehow reuse it in my OSGi module?
Currently I embed it using this method https://dev.liferay.com/en/develop/tutorials/-/knowledge_base/7-1/adding-third-party-libraries-to-a-module
But in this case that jar file is twice in the portal.
Jan
I need PdfBox library to process PDF files in my module. It is already the integral part of the LR portal in \tomcat-9.0.10\webapps\ROOT\WEB-INF\lib\pdfbox.jar
Can I somehow reuse it in my OSGi module?
Currently I embed it using this method https://dev.liferay.com/en/develop/tutorials/-/knowledge_base/7-1/adding-third-party-libraries-to-a-module
But in this case that jar file is twice in the portal.
Jan
Best solution: Just include it in your module.
If you really, really want to use the global version, I think you can add it to the list in the portal-ext property "module.framework.system.packages.extra" to make pdfbox available globally. But it isn't advisable to do so.
https://dev.liferay.com/en/develop/tutorials/-/knowledge_base/7-0/resolving-classnotfoundexception-and-noclassdeffounderror-in-osgi-bundles
If you really, really want to use the global version, I think you can add it to the list in the portal-ext property "module.framework.system.packages.extra" to make pdfbox available globally. But it isn't advisable to do so.
https://dev.liferay.com/en/develop/tutorials/-/knowledge_base/7-0/resolving-classnotfoundexception-and-noclassdeffounderror-in-osgi-bundles
In addition, PDFBox is actually a module too, per https://mvnrepository.com/artifact/org.apache.pdfbox/pdfbox/2.0.14
This means that you can drop PDFBox in the Liferay deploy folder and it will be available as a regular OSGi service.
You can then just @Reference their published components or create classes from their exported packages, easy peasy.
Use "compile", not "compileInclude" or "compileOnly" in your build.gradle file and you should be golden.
This means that you can drop PDFBox in the Liferay deploy folder and it will be available as a regular OSGi service.
You can then just @Reference their published components or create classes from their exported packages, easy peasy.
Use "compile", not "compileInclude" or "compileOnly" in your build.gradle file and you should be golden.
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™