Expand my Community achievements bar.

Run time error java.lang.ClassNotFoundException not found by org.xhtmlrenderer.flying.saucer.pdf.itext5 [613]

Avatar

Level 4

 I'm working on the implementation of html to pdf generation, where i have done below pom config,

 

<dependency>
<groupId>org.xhtmlrenderer</groupId>
<artifactId>flying-saucer-core</artifactId>
<version>9.1.20</version>
</dependency>
<dependency>
<groupId>org.xhtmlrenderer</groupId>
<artifactId>flying-saucer-pdf-openpdf</artifactId>
<version>9.1.20</version>
</dependency>
<dependency>
<groupId>org.xhtmlrenderer</groupId>
<artifactId>flying-saucer-pdf-itext5</artifactId>
<version>9.1.20</version>
</dependency>

<dependency>
<groupId>org.xhtmlrenderer</groupId>
<artifactId>flying-saucer-pdf-osgi</artifactId>
<version>9.1.2</version>
</dependency>
<dependency>
<groupId>org.xhtmlrenderer</groupId>
<artifactId>flying-saucer-core</artifactId>
<version>9.1.20</version>
</dependency>

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

 

and in plugin I have added this line 

<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[
Export-Package:
com.itextpdf;version="5.5.6",\
com.itextpdf.text;version="5.5.6",\
com.itextpdf.text.pdf;version="5.5.6",\
com.lowagie;version="2.1.7",\
org.xhtmlrenderer;version="9.1.20",\
org.xhtmlrenderer.pdf.ITextRenderer.*;version="9.1.20",\

 

The build is fine and the bundle is active. 

In my code I am able to get the apis of ITextRenderer. 

org.xhtmlrenderer.pdf.ITextRenderer iTextRenderer = new org.xhtmlrenderer.pdf.ITextRenderer();

 

But on Runtime I am getting this exception in error.log.

java.lang.ClassNotFoundException: org.xhtmlrenderer.pdf.ITextRenderer

vkarthick_0-1702357287884.png

 

could you please suggest anyone ?

7 Replies

Avatar

Level 6

Hi @vkarthick,

Did you try following things?

  • Restarting AEM instance
  • Using different version of the dependency
  • Check the scope of the dependency. It has to be available at runtime as well. Try with scope "provided".
  • Checking any other error in stack trace.

Avatar

Level 4

Hello @salamswapnil ,

  • Restarting AEM instance - tried but same result.
  • Using different version of the dependency -tried but causing more issue. same version works fine in on prem AEM.
  • Check the scope of the dependency. It has to be available at runtime as well. Try with scope "provided". - its already added
  • Checking any other error in stack trace. - not finding anything useful.

Avatar

Community Advisor

@vkarthick,

Try embedding these 3rd party jar file along with the bundle. You can follow this article on how to embed the 3rd party jars in maven build.

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

Avatar

Level 4

Hello Sudeer,

its already embedded in all/pom.xml.

 

And its working fine in on prem AEM and java 1.8, the problem arose in AEMaaCS. not sure is it becasue of java 11??

Avatar

Level 3

@salamswapnil @Sudheer_Sundalam , 

 

KarthickVe_0-1702986934405.png

 

The resources folder not able to access from dependency.

i'm gettting below error,

 

WARNING: Flying Saucer: No configuration files found in classpath using URL: resources/conf/xhtmlrenderer.conf, resorting to hard-coded fallback properties.

org.xhtmlrenderer.exception WARNING:: Can't load default CSS from /resources/css/XhtmlNamespaceHandler.css.This file must be on your CLASSPATH.

 

if i keep this resource folder under core module it is working fine.

 

does anyone face this issue???

Avatar

Administrator

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

Level 4

@kautuk_sahni , Currently i'm using workaround so i'm still looking for solution.

 

Thanks