Message Boards

Using portal dependencies in DXP 7.0

Joseph Pfohl, modified 5 Years ago.

Using portal dependencies in DXP 7.0

New Member Posts: 2 Join Date: 3/14/19 Recent Posts
I'm working on a portlet for DXP 7.0 and I'd like to use pdfbox.  It looks like the jar is included on the portal classpath but its not accessible to portlets.  I know that I can use portal.dependency.jars=pdfbox.jar in  liferay-plugin-package.propeties, but that's deprecated.  Is there a better way?
thumbnail
David H Nebinger, modified 5 Years ago.

RE: Using portal dependencies in DXP 7.0

Liferay Legend Posts: 14916 Join Date: 9/2/06 Recent Posts
portal.dependency.jars is deprecated, your war file should include all dependencies (some will be masked out during deployment).

OSGi now offers you class loader isolation, so this means you can use (and include) the version of pdf box (and its dependencies) that you want.

Alternatively you can add the pdfbox packages to the module.framework.system.packages.extra property in portal-ext.properties, but this can end up requiring you to expose it and maybe some of its dependant packages as well, and that might not be the best outcome.

According to https://mvnrepository.com/artifact/org.apache.pdfbox/pdfbox/2.0.14, the latest releases of pdfbox are also OSGi bundles. That means that it can be deployed right into the OSGi runtime (by dropping the jar in the Liferay deploy folder). It too may require OSGi deployment of some of its dependencies, but unlike the property option above they would not become global in the class loader hierarchy, just available for binding by OSGi when necessary.