Expand my Community achievements bar.

Something wrong with <Private-Package>or <Import-Package> when trying to add PDFBox

Avatar

Level 7

hi folks,

I can’t use itextpdf anymore for license reasons, so I’ve been trying to integrate PDFBox in my AEM project (AMS, 6.5)

 

I found this project with suggestions on how to do this:

 

https://github.com/ahmed-musallam/pdfbox-osgi-bundle

 

I added the maven-bundle-plugin updates below to my AEM “Java” module. It builds fine and my AEM project shows Active in the console. The PDF tests work ok during compile.

 

However I did notice that some of my Servlets and all of my custom Services are “Satisfied” but not Active.

These services don’t work in my Application.

Any ideas what might be wrong?

 

I didn't have <Private-Package> and <Import-Package> in my maven-bundle-plugin instructions before so I am assuming that it is something there that is wrong..... (it is like it is making my  *Impl* classes unavailable..)

 

Thanks

Fiona

 

Log errors

 

Servlet

 

*ERROR* [FelixDispatchQueue] org.apache.sling.servlets.resolver FrameworkEvent ERROR (org.osgi.framework.ServiceException: Service factory returned null. (Component: com.xxx.servlets.xxxxx (1234)))

error.log:org.osgi.framework.ServiceException: Service factory returned null. (Component: com.xxx.servlets.xxxxx (1234))

 

Service ( called by Servlet)

DDA.log:org.osgi.framework.ServiceException: Service factory exception: Could not load implementation object class com.xxx.services.impl.SomethingServiceImpl

DDA.log:Caused by: java.lang.IllegalStateException: Could not load implementation object class com.xxx.services.impl.SomethingServiceImpl

stderr.log:ERROR : bundle com.xxx.xxx:1.0.0.SNAPSHOT (111)[com.xxx.services.impl.SomethingServiceImpl(123)] : Could not load implementation object class com.xxx.services.impl.SomethingServiceImp

 

 

<plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <version> 4.2.1</version>
    <extensions>true</extensions>
    <configuration>
        <instructions>
            <Private-Package>org.bouncycastle.*</Private-Package>
            <Import-Package>
                sun.java2d.cmm;resolution:=optional,
                sun.java2d.cmm.*;resolution:=optional,
                *
            </Import-Package>
            <Embed-Dependency>
                pdfbox,
                fontbox
            </Embed-Dependency>
        </instructions>
    </configuration>
</plugin>

:


<!-- https://mvnrepository.com/artifact/org.apache.pdfbox/pdfbox -->
<dependency>
    <groupId>org.apache.pdfbox</groupId>
    <artifactId>pdfbox</artifactId>
    <version>2.0.16</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.pdfbox/fontbox -->
<dependency>
    <groupId>org.apache.pdfbox</groupId>
    <artifactId>fontbox</artifactId>
    <version>2.0.16</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.bouncycastle/bcprov-jdk15on -->
<dependency>
    <groupId>org.bouncycastle</groupId>
    <artifactId>bcprov-jdk15on</artifactId>
    <version>1.62</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.bouncycastle/bcpkix-jdk15on -->
<dependency>
    <groupId>org.bouncycastle</groupId>
    <artifactId>bcpkix-jdk15on</artifactId>
    <version>1.62</version>
</dependency>

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Reply

Avatar

Community Advisor

Hi @fionas76543059 Did you try with just the pdf box dependency in pom?

 

<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>2.0.20</version>
</dependency>
 
Just with that I am not seeing similar issue for existing bundles