Unresolved requirements: osgi.wiring.package=org.xhtmlrenderer.pdf in AEM | Community
Skip to main content
Mario248
Level 7
September 21, 2023
Solved

Unresolved requirements: osgi.wiring.package=org.xhtmlrenderer.pdf in AEM

  • September 21, 2023
  • 5 replies
  • 8437 views

I want to use ITextRenderer to generate a PDF so I have added maven depdency in parent POM and core module POM,

 

Parent POM

 

<dependency> <groupId>org.xhtmlrenderer</groupId> <artifactId>flying-saucer-pdf-itext5</artifactId> <version>9.0.1</version> </dependency>

 

 
Core POM

 

<dependency> <groupId>org.xhtmlrenderer</groupId> <artifactId>flying-saucer-pdf-itext5</artifactId> </dependency>

 

I am importing import org.xhtmlrenderer.pdf.ITextRenderer in java class. I dont see any error in compilation but after deployment in AEM, the core bundle is in "INSTALLED" state. when I check error it says "org.xhtmlrenderer.pdf -- Cannot be resolved"

 

 

Do I need to add any import package in order to resolve the dependency issue ? if yes where should i add ?

 Below is my  bnd-maven-plugin plugn in core POM,

 

 

<plugin> <groupId>biz.aQute.bnd</groupId> <artifactId>bnd-maven-plugin</artifactId> <executions> <execution> <id>bnd-process</id> <goals> <goal>bnd-process</goal> </goals> <configuration> <bnd><![CDATA[ Import-Package: javax.annotation;version=0.0.0,* ]]></bnd> </configuration> </execution> </executions> </plugin>

 

 

Error message:

 

21.09.2023 15:06:52.498 *ERROR* [qtp1931268691-1951] org.apache.felix.http.jetty Bundles: Cannot start (org.osgi.framework.BundleException: Unable to resolve aem-core.core [674](R 674.53): missing requirement [aem-core.core [674](R 674.53)] osgi.wiring.package; (osgi.wiring.package=org.xhtmlrenderer.pdf) Unresolved requirements: [[aem-core.core [674](R 674.53)] osgi.wiring.package; (osgi.wiring.package=org.xhtmlrenderer.pdf)]) org.osgi.framework.BundleException: Unable to resolve aem-core.core [674](R 674.53): missing requirement [aem-core.core [674](R 674.53)] osgi.wiring.package; (osgi.wiring.package=org.xhtmlrenderer.pdf) Unresolved requirements: [[aem-core.core [674](R 674.53)] osgi.wiring.package; (osgi.wiring.package=org.xhtmlrenderer.pdf)] at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4368) at org.apache.felix.framework.Felix.startBundle(Felix.java:2281) at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:998) at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:984) at org.apache.felix.webconsole.internal.core.BundlesServlet.doPost(BundlesServlet.java:365) [org.apache.felix.webconsole:4.6.2] at javax.servlet.http.HttpServlet.service(HttpServlet.java:644) [org.apache.felix.http.servlet-api:1.1.2]

 

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

The basic problem is, that it's not sufficient just to declare the dependency, but also deploy the dependent into AEM (as it's there ootb). This is what you are seeing.

That means, you either deploy these dependent libraries as bundles on their own, or you embed these libraries into your bundle, so they can get resolved internally (within the bundle), not requiring any external bundle.

5 replies

Mahedi_Sabuj
Community Advisor
Community Advisor
September 21, 2023

In the majority of instances involving third-party bundles, the resolution of the Maven dependency in both the main pom.xml and the core pom.xml results in the successful inclusion of the required bundle.

Nevertheless, there are situations where this automatic process does not occur as expected. In such scenarios, it becomes necessary to prepare the dependency for OSGi compatibility and then embed it into the system.

To accomplish this, you can refer to the instructions provided in the documentation. 
https://myaemlearnings.blogspot.com/2021/08/embedding-third-party-dependencyosgi.html

Mahedi Sabuj
Mario248
Mario248Author
Level 7
September 21, 2023

Thanks for your input. For testing purpose, I tried to download the dependency from https://mvnrepository.com/artifact/org.xhtmlrenderer/flying-saucer-pdf-itext5/9.0.1 and tried to install directly in system console and ended up below error 

Then I tried to extract the jar and checked the below MANIFEST.MF file 

 

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: pbrant
Build-Jdk: 1.6.0_21

 

Seems like it does not have "Bundle-SymbolicName". Can you tell me how to proceed ?

 

Mahedi_Sabuj
Community Advisor
Community Advisor
September 21, 2023

Can you try using below OSGI compatible version

<dependency> <groupId>org.xhtmlrenderer</groupId> <artifactId>flying-saucer-pdf-osgi</artifactId> <version>9.2.2</version> </dependency>

https://mvnrepository.com/artifact/org.xhtmlrenderer/flying-saucer-pdf-osgi

Mahedi Sabuj
Jagadeesh_Prakash
Community Advisor
Community Advisor
September 21, 2023

@mario248  can you try using below version org.xhtmlrenderer

 

<dependencies>
<!-- Other dependencies -->

<!-- XhtmlRenderer (Flying Saucer) for PDF generation -->
<dependency>
<groupId>org.xhtmlrenderer</groupId>
<artifactId>flying-saucer-pdf</artifactId>
<version>9.1.22</version> <!-- Specify the version you need -->
</dependency>
</dependencies>

 

 

Mario248
Mario248Author
Level 7
September 21, 2023

I tried with this dependency but it failed in compilation org.xhtmlrenderer.pdf.ITextRenderer package does not exist. I think I should keep 

<dependency>
<groupId>org.xhtmlrenderer</groupId>
<artifactId>flying-saucer-pdf-itext5</artifactId>
<version>9.0.1</version>
</dependency>
kautuk_sahni
Community Manager
Community Manager
September 21, 2023

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

Kautuk Sahni
Sudheer_Sundalam
Community Advisor
Community Advisor
September 21, 2023

@mario248 ,

Please try by modifying the bnd plugin configuration as below

<plugin> <groupId>biz.aQute.bnd</groupId> <artifactId>bnd-maven-plugin</artifactId> <executions> <execution> <id>bnd-process</id> <goals> <goal>bnd-process</goal> </goals> <configuration> <bnd><![CDATA[ Import-Package: javax.annotation;version=0.0.0,* -includeresource: flying-saucer-pdf-itext5-9.0.1.jar;lib:=true ]]></bnd> </configuration> </execution> </executions> </plugin>

More explanation of embedding 3rd party jars using BND plugin can be found at this excellent blog article: https://myaemlearnings.blogspot.com/2021/12/embed-third-party-dependency-using-bnd.html

 

Mario248
Mario248Author
Level 7
September 21, 2023

Thanks for your input. I have below dependency

<dependency> <groupId>org.xhtmlrenderer</groupId> <artifactId>flying-saucer-pdf-osgi</artifactId> <version>9.2.2</version> </dependency> <dependency> <groupId>org.xhtmlrenderer</groupId> <artifactId>flying-saucer-pdf</artifactId> <version>9.2.2</version> </dependency><plugin> <groupId>biz.aQute.bnd</groupId> <artifactId>bnd-maven-plugin</artifactId> <executions> <execution> <id>bnd-process</id> <goals> <goal>bnd-process</goal> </goals> <configuration> <bnd><![CDATA[ Import-Package: javax.annotation;version=0.0.0,* -includeresource: flying-saucer-pdf-osgi-9.2.2.jar;lib:=true ]]></bnd> </configuration> </execution> </executions> </plugin>

I am getting following error, 

21.09.2023 21:17:12.096 *ERROR* [qtp1931268691-2420] org.apache.felix.http.jetty Bundles: Cannot start (org.osgi.framework.BundleException: Unable to resolve core.core [686](R 686.2): missing requirement [core.core [686](R 686.2)] osgi.wiring.package; (&(osgi.wiring.package=org.xhtmlrenderer.pdf)(version>=9.2.0)(!(version>=10.0.0))) Unresolved requirements: [[core.core [686](R 686.2)] osgi.wiring.package; (&(osgi.wiring.package=org.xhtmlrenderer.pdf)(version>=9.2.0)(!(version>=10.0.0)))])
org.osgi.framework.BundleException: Unable to resolve core.core [686](R 686.2): missing requirement [core.core [686](R 686.2)] osgi.wiring.package; (&(osgi.wiring.package=org.xhtmlrenderer.pdf)(version>=9.2.0)(!(version>=10.0.0))) Unresolved requirements: [[core.core [686](R 686.2)] osgi.wiring.package; (&(osgi.wiring.package=org.xhtmlrenderer.pdf)(version>=9.2.0)(!(version>=10.0.0)))]
at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4368)
at org.apache.felix.framework.Felix.startBundle(Felix.java:2281)

 

Sudheer_Sundalam
Community Advisor
Community Advisor
September 21, 2023

@mario248 ,

In that case, also add the flying-saucer-pdf-9.2.2.jar in the includeresource configuration.

-includeresource: flying-saucer-pdf-osgi-9.2.2.jar;flying-saucer-pdf-9.2.2.jar;lib:=true

 

joerghoh
Adobe Employee
joerghohAdobe EmployeeAccepted solution
Adobe Employee
September 23, 2023

The basic problem is, that it's not sufficient just to declare the dependency, but also deploy the dependent into AEM (as it's there ootb). This is what you are seeing.

That means, you either deploy these dependent libraries as bundles on their own, or you embed these libraries into your bundle, so they can get resolved internally (within the bundle), not requiring any external bundle.