Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

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

Avatar

Level 9

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"

 

Mario248_0-1695289899819.png

 

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]

 

1 Accepted Solution

Avatar

Correct answer by
Employee

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.

View solution in original post

16 Replies

Avatar

Community Advisor

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

Avatar

Level 9

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 

Mario248_0-1695296604757.png

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 ?

 

Avatar

Community Advisor

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

Avatar

Level 9

Interesting that it has OSGI version. Thanks for sharing it. I used above artifact "flying-saucer-pdf-osgi" inn my POM. But still my core bundle is in INSTALLED state. Below is the error core bundle error 

Mario248_0-1695306235531.png

 

Error LOG 

21.09.2023 19:54:07.406 *ERROR* [qtp1931268691-2288] org.apache.felix.http.jetty Bundles: Cannot start (org.osgi.framework.BundleException: Unable to resolve core-connector.core [686](R 686.0): missing requirement [core-connector.core [686](R 686.0)] osgi.wiring.package; (&(osgi.wiring.package=org.xhtmlrenderer.pdf)(version>=9.2.0)(!(version>=10.0.0))) Unresolved requirements: [[core-connector.core [686](R 686.0)] 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-connector.core [686](R 686.0): missing requirement [core-connector.core [686](R 686.0)] osgi.wiring.package; (&(osgi.wiring.package=org.xhtmlrenderer.pdf)(version>=9.2.0)(!(version>=10.0.0))) Unresolved requirements: [[core-connector.core [686](R 686.0)] 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)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:998)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:984)

 

I tried to switched to last 5 previous version but getting similar error. Additionally I tried to download the jar (https://mvnrepository.com/artifact/org.xhtmlrenderer/flying-saucer-pdf-osgi/9.2.2) and installed manually in system console to see what is happening. Below is error message, 

 

Mario248_1-1695306424218.png

 

Any idea?

Avatar

Community Advisor

Could you also include "flying-saucer-pdf" as a dependency 

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

https://github.com/flyingsaucerproject/flyingsaucer/blob/main/flying-saucer-pdf-osgi/pom.xml

 

 

Avatar

Level 9

Added both dependencies but still bundle is not active state.

 

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

Mario248_0-1695310617148.png

 

Error -

21.09.2023 21:01:37.081 *ERROR* [qtp1931268691-2435] org.apache.felix.http.jetty Bundles: Cannot start (org.osgi.framework.BundleException: Unable to resolve core.core [686](R 686.1): missing requirement [core.core [686](R 686.1)] osgi.wiring.package; (&(osgi.wiring.package=org.xhtmlrenderer.pdf)(version>=9.2.0)(!(version>=10.0.0))) Unresolved requirements: [[core.core [686](R 686.1)] 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.1): missing requirement [core.core [686](R 686.1)] osgi.wiring.package; (&(osgi.wiring.package=org.xhtmlrenderer.pdf)(version>=9.2.0)(!(version>=10.0.0))) Unresolved requirements: [[core.core [686](R 686.1)] 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)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:998)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:984)

 

Avatar

Community Advisor

I would recommend to create a dedicated "common.core" module to include all third-party dependencies. Afterward, you can embed the "common.core" artifact into all pom.xml.

Please make sure you've added third-party dependencies to both root and core pom.xml as well.

https://myaemlearnings.blogspot.com/2021/08/embedding-third-party-dependencyosgi.html 

Avatar

Level 9

We can embed third party libraries using POM. But why is it failing when I try to install the third party bundle in system console? The same may happen building and deploying jars from maven(POM). Is my question valid ?

Avatar

Community Advisor

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

 

 

Avatar

Level 9

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>

Avatar

Administrator

@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

Avatar

Community Advisor

@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

 

Avatar

Level 9

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)
Mario248_1-1695311379965.png

 

Avatar

Community Advisor

@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

 

Avatar

Level 9

Thanks,. Included the resources(flying-saucer-pdf-osgi-9.2.2.jar,flying-saucer-pdf-9.2.2.jar) and I could see that is added in Bundle Classpath, but still some packages are not resolved. Should I do any kind import/export package ?

Mario248_1-1695366549183.png

 

Avatar

Correct answer by
Employee

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.