Skip to main content
Level 4
Nov 22, 2024 3:35 PM UTC

Issue with OSGi Bundle in Installed State After Adding Apache PDFBox to bnd-baseline-maven-plugin

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>

 

Problem:

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:

 



 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

11 replies

Tethich
Community Advisor
Community Advisor
Nov 22, 2024 4:15 PM UTC

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

Translate
georhe6Author
Level 4
Nov 22, 2024 7:39 PM UTC

Thanks @tethich , for the feedback.

I did not make any changes at Sling configs level ,after adding these dependencies I am getting the error.

Translate
Manu_Mathew_
Community Advisor
Community Advisor
Nov 22, 2024 5:23 PM UTC

@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

 

Translate
georhe6Author
Level 4
Nov 22, 2024 7:41 PM UTC

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 

Translate
Fanindra_Surat
Community Advisor
Community Advisor
Nov 22, 2024 6:48 PM UTC

Hi @georhe6 - Here's a thread from our community https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/can-we-use-pdf-library-with-aem-6-5-18/m-p/652920 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,

Translate
georhe6Author
Level 4
Nov 22, 2024 7:42 PM UTC

Thanks @fanindra_surat , Thanks
Similar issues I am facing with Itextpdf also,
Can you suggest any version which i can try

Translate
Fanindra_Surat
Community Advisor
Community Advisor
Nov 22, 2024 9:29 PM UTC

I can try few and confirm you. What's your AEM version?

Translate
Ritesh_Mittal
Adobe Champion and Community Advisor
Adobe Champion and Community Advisor
Nov 23, 2024 4:21 PM UTC

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-

  1. Add below to your java command or AEM startup script:

--add-exports=java.desktop/sun.java2d.cmm=ALL-UNNAMED

  1. Add the below line to sling.properties:

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

Translate
Shashi_Mulugu
Community Advisor and User Group Leader
Community Advisor and User Group Leader
Nov 23, 2024 8:37 PM UTC

@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.

Translate
georhe6Author
Level 4
Nov 29, 2024 2:42 AM UTC

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>


 

Translate