question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

IIOProviderContextListener -> NoClassDefFoundError with apache pdfbox JBIG2 ImageIO plugin

See original GitHub issue

I don’t sure if the problem is with IIOProviderContextListener or in Apache PDFBox JBIG2 ImageIO plugin, but sometimes I get a NoClassDefFoundError when I restart a servlet aplication on a Tomcat.

java.lang.NoClassDefFoundError: Could not initialize class org.apache.pdfbox.jbig2.JBIG2ImageReader
    at org.apache.pdfbox.jbig2.JBIG2ImageReaderSpi.createReaderInstance(JBIG2ImageReaderSpi.java:117)
    at javax.imageio.spi.ImageReaderSpi.createReaderInstance(ImageReaderSpi.java:320)
    at javax.imageio.ImageIO$ImageReaderIterator.next(ImageIO.java:529)
    at javax.imageio.ImageIO$ImageReaderIterator.next(ImageIO.java:513)
    at org.apache.pdfbox.filter.Filter.findImageReader(Filter.java:155)
    at org.apache.pdfbox.filter.JBIG2Filter.decode(JBIG2Filter.java:67)
    at org.apache.pdfbox.cos.COSInputStream.create(COSInputStream.java:84)
    at org.apache.pdfbox.cos.COSStream.createInputStream(COSStream.java:175)
    at org.apache.pdfbox.pdmodel.common.PDStream.createInputStream(PDStream.java:241)
    at org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject.createInputStream(PDImageXObject.java:735)
    at org.apache.pdfbox.pdmodel.graphics.image.SampledImageReader.from1Bit(SampledImageReader.java:253)
    at org.apache.pdfbox.pdmodel.graphics.image.SampledImageReader.getRGBImage(SampledImageReader.java:212)
    at org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject.getImage(PDImageXObject.java:444)
    at org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject.getImage(PDImageXObject.java:425)
    at org.apache.pdfbox.rendering.PageDrawer.drawImage(PageDrawer.java:1100)
    at org.apache.pdfbox.contentstream.operator.graphics.DrawObject.process(DrawObject.java:63)
    at org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:869)
    at org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:505)
    at org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:479)
    at org.apache.pdfbox.contentstream.PDFStreamEngine.processPage(PDFStreamEngine.java:152)
    at org.apache.pdfbox.rendering.PageDrawer.drawPage(PageDrawer.java:263)
    at org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:321)
    at org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:243)
    at org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:203)
    at com.digibis.digiimage.pdf.pdfbox.PdfBoxPdfProcessor.getImageFromDocumentPage(PdfBoxPdfProcessor.java:105)
 ...

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
Zardoz89commented, Oct 21, 2019

EUREKA! It’s these two services! It’s the exactly the same problem that your listener fixes for the ImageIO SPI service, but it happens with his CacheFactory and LoggerFactory services. I removed both and replaced his Logger wraper to JUL, by SLF4J and his CacheFactory by a simple instance of his cache implementation. Now I can’t reproduce anymore the bug! So, or they does what I did or I/they create a listener to unregister his services like you Listener does for ImageIO SPI

1reaction
haraldkcommented, Oct 21, 2019

Good to hear you found a fix!

I’m closing this here for now, as the changes must be done on the PDFBox/JBig2 side.

– Harald K

Read more comments on GitHub >

github_iconTop Results From Across the Web

[#PDFBOX-4671] NoClassDefFoundError: Could not initialize ...
JBIG2 ImageIO plugin sometimes does a NoClassDefFoundError I'm using TwelveMonkeys IIOProviderContextListener to fix the problem of ImageIO ...
Read more >
Could not initialize class org.apache.pdfbox.jbig2 ...
When trying to use pdfbox jbig2-3.0.2 plugin with IcePDF-6.3.2 library, ... JBIG2 ImageIO plugin sometimes does a NoClassDefFoundError > I'm ...
Read more >
JBig2 not resolved at runtime? - Stack Overflow
PdfBox is using Apache commons logging. ... PDDocument"); } catch (ClassNotFoundException e) { System.err.println("PdfBox classes not found!
Read more >
could not initialize class javax.imageio.imageio - You.com
I don't sure if the problem is with IIOProviderContextListener or in Apache PDFBox JBIG2 ImageIO plugin, but sometimes I get a NoClassDefFoundError when...
Read more >
Open Source Software Components - i-net PDFC
The Calendar plugin allows the Task Planner to read iCal and ICS files and run a ... PDFBox JBIG2 ImageIO plugin, jbig2-imageio.jar, 3.0.4,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found