[
https://issues.apache.org/jira/browse/FOP-3296?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18060679#comment-18060679
]
Simon Steiner commented on FOP-3296:
------------------------------------
org/apache/pdfbox/io/RandomAccessRead comes from a fontbox dependency called
pdfbox-io
> 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)