[jira] [Closed] (FOP-3296) pdfbox:3.0.3 test-scoped in fop-core-2.11.pom causes NoClassDefFoundError at runtime

"Ole Sandum (Jira)" <[email protected]> Thu, 26 Feb 2026 14:32:00 +0000 (UTC)
Newsgroups gmane.text.xml.fop.devel
Message-ID <[email protected]>
     [ https://issues.apache.org/jira/browse/FOP-3296?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ole Sandum closed FOP-3296.
---------------------------
    Resolution: Invalid

Closing this as invalid. Apologies for the noise. 😳

After testing without any explicit pdfbox dependency in the consuming project, the transitive chain fop-core:2.11 → fontbox:3.0.3 → pdfbox-io:3.0.3 resolves correctly and RandomAccessRead is available at runtime as expected.

The exact cause of the original error evades me. Perhaps linked to our internal maven proxy not having pdfbox-io:3.0.3 cached at the time we first built against FOP 2.11, but . Once cached,
everything works as designed.

Simon's comment was correct. Thanks for the pointer.

> pdfbox:3.0.3 test-scoped in fop-core-2.11.pom causes NoClassDefFoundError at runtime
> ------------------------------------------------------------------------------------
>
>                 Key: FOP-3296
>                 URL: https://issues.apache.org/jira/browse/FOP-3296
>             Project: FOP
>          Issue Type: Bug
>    Affects Versions: 2.11
>            Reporter: Ole Sandum
>            Assignee: Simon Steiner
>            Priority: Major
>
> After upgrading from FOP 2.10 to 2.11, applications encounter:
> {code:java}
> java.lang.NoClassDefFoundError: org/apache/pdfbox/io/RandomAccessRead{code}
> This happens whenever FOP processes OTF or CFF fonts.
> *Root cause*
> fop-core-2.11.pom declares pdfbox:3.0.3 as test-scoped:
> {code:xml}
> <dependency>
>   <groupId>org.apache.pdfbox</groupId>
>   <artifactId>pdfbox</artifactId>
>   <version>3.0.3</version>
>   <scope>test</scope>
> </dependency>{code}
> However, FOP 2.11's own production classes directly reference classes from
> that artifact. Inspection of the bytecode confirms:
>    org.apache.fop.fonts.CFFToType1Font references
>       org/apache/pdfbox/io/RandomAccessReadBuffer
>       org/apache/pdfbox/io/RandomAccessRead (via CFFParser.parse signature)
>    org.apache.fop.fonts.truetype.OTFFile references the same
> Additionally, fontbox:3.0.3 (compile-scoped) contains classes such as
> DataInputRandomAccessRead that implement org.apache.pdfbox.io.RandomAccessRead.
> Since pdfbox:3.0.3 is test-scoped it is absent from consumers' runtime
> classpaths, so the JVM cannot resolve RandomAccessRead when loading these
> font classes.
> The problem did not exist with FOP 2.10 because fontbox:2.0.27 had no
> dependency on org.apache.pdfbox.io.RandomAccessRead.
> *Fix*
> Change the scope of pdfbox:3.0.3 in fop-core's pom from test to compile
> (or runtime).
> *Workaround*
> Add an explicit pdfbox:3.0.3 compile-scope dependency in the consuming project.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)