Expand my Community achievements bar.

SOLVED

runtime error for org.xhtmlrenderer.pdf.ITextRenderer

Avatar

Level 1

I am trying to do a poc for html to pdf generation.

I am using the dependency as below. 

 

<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 

<Import-Package>javax.inject;version=0.0.0,org.xhtmlrenderer.*;resolution:=optional,*</Import-Package>

 

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

 

Anyone please help ? 

1 Accepted Solution

Avatar

Correct answer by
Level 4

Looks like Depedency is not enough to cover this package to get imported for PDF package "org.xhtmlrenderer.pdf.ITextRenderer iTextRenderer" as it is still in installed state.

 

If you are building this using Eclipse, After package build please see if you find the below JAR getting downloaded in Eclipse with this respected class available "org.xhtmlrenderer.pdf.ITextRenderer iTextRenderer". If not means you are missing the depdency to fullfill the package requirement for "org.xhtmlrenderer.pdf.ITextRenderer iTextRenderer".

 

View solution in original post

4 Replies

Avatar

Community Advisor

Hi @Dipanjan1986 

Does itextpdf is in your bundle classpath? If not try adding to your bundle and check once.

AG

Avatar

Level 1

I already tried that option  with <Embed-Dependency> and <Bundle-ClassPath>. Bundle becomes in 'installed' state. and the errors comes as below.

com.itextpdf.text,version=[5.5,6) -- Cannot be resolved
com.itextpdf.text.pdf,version=[5.5,6) -- Cannot be resolved
com.lowagie.text,version=[1.3,2) -- Cannot be resolved
com.lowagie.text.pdf,version=[1.3,2) -- Cannot be resolved

Avatar

Community Advisor
Hi @Dipanjan1986, add com.itextpdf also to import package list. If it doesn't has any dependencies, it will resolve.

Avatar

Correct answer by
Level 4

Looks like Depedency is not enough to cover this package to get imported for PDF package "org.xhtmlrenderer.pdf.ITextRenderer iTextRenderer" as it is still in installed state.

 

If you are building this using Eclipse, After package build please see if you find the below JAR getting downloaded in Eclipse with this respected class available "org.xhtmlrenderer.pdf.ITextRenderer iTextRenderer". If not means you are missing the depdency to fullfill the package requirement for "org.xhtmlrenderer.pdf.ITextRenderer iTextRenderer".