Pipeline compilation failure due to PDFBox library in AEM as a Cloud Service
Pipeline compilation in ÃÛ¶¹ÊÓÆµ Experience Manager (AEM) as a Cloud Service fails when the PDFBox library isn’t properly embedded as an OSGi-compliant bundle. This results in unresolved dependencies and analyzer errors during the build process. To fix this, you need to wrap PDFBox and its dependencies in a dedicated OSGi bundle, update your project’s POM files, and ensure the correct build order and plugin versions.
Description description
Environment
ÃÛ¶¹ÊÓÆµ Experience Manager (AEM) as a Cloud Service – Sites (Development environment)
Issue/Symptoms
- Warnings indicating that bundles such as
pdfbox-io:3.0.1
andpdfbox:3.0.1
import packages without specifying version ranges. - Errors stating that required packages from PDFBox are not exported at the necessary OSGi start level, resulting in unresolved dependencies during runtime:
2025-05-28 11:31:04.782 The analyser found the following errors for author and publish : 2025-05-28 11:31:04.783 [ api-regions-exportsimports] <custom>-<bundle>-project.core:0.0.1-SNAPSHOT: Bundle <custom>-<bundle>-project.core:0.0.1-SNAPSHOT is importing package(s) [ org.apache.pdfbox.pdmodel.common.filespecification, org.apache.pdfbox.multipdf, org.apache.pdfbox.pdmodel] in start level 20 but no bundle is exporting these for that start level. (com.<custom>.<code>:<custom>-<bundle>-project.all:0.0.1-SNAPSHOT)
- The issue occurs only in the cloud environment; local builds compile successfully.
- Attempts to embed PDFBox using
filter.xml
or modifying POM files have failed.
Resolution resolution
To resolve this issue, ensure that all dependencies are properly embedded and configured for AEM’s OSGi runtime environment:
-
Create a separate module to wrap PDFBox as an OSGi bundle.
- Include all required dependencies, such as FontBox.
- Use the Apache Felix Maven Bundle Plugin to export packages explicitly.
-
Update the
all/pom.xml
file.-
Add an embedded entry for the PDFBox wrapper module:
code language-none <embedded> <groupId>com.<custom>.<code></groupId> <artifactId><custom>-<bundle>-project.pdfbox-wrapper</artifactId> <type>jar</type> <target>/apps/custom-packages/application/install</target> </embedded>
-
Declare a dependency for the wrapper module:
code language-none <dependency> <groupId>com.<custom>.<code></groupId> <artifactId><custom>-<bundle>-project.pdfbox-wrapper</artifactId> <version>0.0.1-SNAPSHOT</version> <type>jar</type> </dependency>
-
-
Ensure the wrapper module builds before other modules that depend on it by ordering modules correctly in the aggregator POM file.
-
Upgrade the
filevault-package-maven-plugin
to version 1.1.5 or later if your current version doesn’t support tags like<version>
inside<embedded>
. -
Run
mvn clean install
locally to verify:- The wrapper JAR is created with correct manifest entries.
- The artifact appears under
/apps/custom-packages/application/install
.
-
Deploy the updated package via Cloud Manager pipeline and confirm that analyzer errors no longer occur.