I'm facing an issue with my OSGi bundle, which remains in the Installed state after adding Apache PDFBox dependencies to my bnd-baseline-maven-plugin. Here's my setup:
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>2.0.9</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>fontbox</artifactId>
<version>2.0.9</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk15on</artifactId>
<version>1.61</version>
</dependency>
bnd Configuration:
<bnd><![CDATA[
Import-Package: javax.annotation,*,!org.bouncycastle.*
-exportcontents: ${packages;VERSIONED}
-conditionalpackage: org.apache.pdfbox.*,org.apache.fontbox.*,org.bouncycastle.*
Bundle-DocURL:
-plugin org.apache.sling.caconfig.bndplugin.ConfigurationClassScannerPlugin
]]></bnd>
After installing the bundle, I receive the following error:
sun.java2d.cmm.kcms -- Cannot be resolved and overwritten by Boot Delegation
Additionally, I see the following messages in the bundle:
Views
Replies
Total Likes
Hi @georhe6
You could first check you Sling configs, maybe you have something in the bootdelegation property that leads to these errors.
Please rewd this documentation, maybe it helps https://sling.apache.org/documentation/configuration.html#osgi-boot-delegation-support-1
@georhe6 The "Installed" state typically means the bundle could not resolve dependencies. Ensure all the transitive dependencies are resolved and versions are aligned as per the dependency related doc.
- Maybe try updating java to higher versions.
- Try updating pdfbox versions to the latest one.(supporting to current java/JVM)
- Maybe try adding this to the config.properties file:
org.osgi.framework.bootdelegation=sun.java2d.cmm.kcms
- Or you could try Modifying the Bundle's Import-Package Directive to something like- Import-Package: sun.java2d.cmm.kcms;resolution:=optional
Thanks @Manu_Mathew_ ,
We are using java 11 , I have tried with latest versions of pdfbox .
Can you please review the bnd config please.
Both pdfbox and felix are inside org.apache ,I assume some dependency conflict
Views
Replies
Total Likes
Hi @georhe6 - Here's a thread from our community https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/can-we-use-pdf-library-wit... on similar issue. Seems like a lower version of the pdfbox works in some cases, and an alternate option of itextpdf has also been discussed.
Regards,
Thanks @Fanindra_Surat , Thanks
Similar issues I am facing with Itextpdf also,
Can you suggest any version which i can try
Views
Replies
Total Likes
I can try few and confirm you. What's your AEM version?
Views
Replies
Total Likes
Hi @georhe6 ,
The error sun.java2d.cmm.kcms -- Cannot be resolved and overwritten by Boot Delegation typically happens due to JDK version compatibility or misconfigured OSGi boot delegation.
Could you try below-
--add-exports=java.desktop/sun.java2d.cmm=ALL-UNNAMED
org.osgi.framework.bootdelegation=sun.java2d.cmm.*,*
This will expose the required class and handle boot delegation correctly.
Let me know if this works.
Thanks,
Ritesh Mittal
@georhe6 Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.
Views
Replies
Total Likes
I was able to resolve the issue finally by using ItextPDF
Below my pom:
<bnd><![CDATA[
Import-Package: javax.annotation,*;resolution:=optional
-exportcontents: ${packages;VERSIONED}
-dsannotations-options: inherit
-conditionalpackage: com.itextpdf.*,\
com.itextpdf.kernel.*,\
com.itextpdf.forms.*,\
]]></bnd>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itext-core</artifactId>
<version>8.0.1</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.5.13.4</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>kernel</artifactId>
<version>8.0.5</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>forms</artifactId>
<version>8.0.5</version>
</dependency>
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies