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>
<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]
Solved! Go to Solution.
Views
Replies
Total Likes
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.
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
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 ?
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
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
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,
Any idea?
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
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>
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)
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
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 ?
@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>
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>
@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.
Views
Replies
Total Likes
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
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,
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
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 ?
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.
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies