org.apache.pdfbox.exceptions.COSVisitorException: java.lang.IndexOutOfBoundsException: Index: 72, Size: 0

Apache's JIRA Issue Tracker | James Green | 4 years ago
  1. 0

    [PDFBOX-1586] IndexOutOfBoundsException when saving a document (at random) - ASF JIRA

    apache.org | 1 year ago
    org.apache.pdfbox.exceptions.COSVisitorException: java.lang.IndexOutOfBoundsException: Index: 72, Size: 0
  2. 0

    Getting the following stacktrace: org.apache.pdfbox.exceptions.COSVisitorException: java.lang.IndexOutOfBoundsException: Index: 28, Size: 0 at org.apache.pdfbox.pdfwriter.COSWriter.visitFromStream(COSWriter.java:1245) at org.apache.pdfbox.cos.COSStream.accept(COSStream.java:201) at org.apache.pdfbox.cos.COSObject.accept(COSObject.java:206) at org.apache.pdfbox.pdfwriter.COSWriter.doWriteObject(COSWriter.java:524) at org.apache.pdfbox.pdfwriter.COSWriter.doWriteBody(COSWriter.java:434) at org.apache.pdfbox.pdfwriter.COSWriter.visitFromDocument(COSWriter.java:1056) at org.apache.pdfbox.cos.COSDocument.accept(COSDocument.java:496) at org.apache.pdfbox.pdfwriter.COSWriter.write(COSWriter.java:1392) at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1157) at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1138) ... Caused by: java.lang.IndexOutOfBoundsException: Index: 28, Size: 0 at java.util.ArrayList.rangeCheck(ArrayList.java:604) at java.util.ArrayList.get(ArrayList.java:382) at org.apache.pdfbox.io.RandomAccessBuffer.seek(RandomAccessBuffer.java:84) at org.apache.pdfbox.io.RandomAccessFileInputStream.read(RandomAccessFileInputStream.java:96) at java.io.BufferedInputStream.fill(BufferedInputStream.java:235) at java.io.BufferedInputStream.read1(BufferedInputStream.java:275) at java.io.BufferedInputStream.read(BufferedInputStream.java:334) at org.apache.pdfbox.pdfwriter.COSWriter.visitFromStream(COSWriter.java:1232) I'll add some context. We have a "data pipeline" in which a Windows Print Monitor sends postscript into a servlet which then uses GhostScript 9.05 to convert in-memory to PDF. This PDF is then loaded into PDFBox using PDDocument.load(). At this point we split the original PDF into multiple smaller ones each of which is saved to a ByteArrayOutputStream. At the point of save() we are having serious reliability issues. Taking an original PDF from Ghostscript we have saved this into a unit test to replicate the problem without success. If we attempt to re-execute the pipeline to take the original PDF and split it, we get apparently random percentages of saved documents. For instance, on a 990 page document (text, no images), to be split into 990 1-page documents using Tomcat 7 with -Xmx=512m: Pass 1: 50% were saved, 50% ended with stack traces Pass 2: 100% were saved Pass 3: 100% were saved The same test with -Xmx=128m ended several times with just 1 document saved, the rest were stack traces. We have also seen this randomly hit a sample document consisting of four pages to be split into two two-page documents so it does not appear to be memory related. We also added code to catch the IndexOutOfBoundsException and make up to ten attempts to repeat, but it seems the save() either works the first time or not at all. We're thinking there are environmental factors here but we're now focused on getting this nailed. Any advice or assistance will be welcomed.

    Apache's JIRA Issue Tracker | 4 years ago | James Green
    org.apache.pdfbox.exceptions.COSVisitorException: java.lang.IndexOutOfBoundsException: Index: 72, Size: 0
  3. 0

    Getting the following stacktrace: org.apache.pdfbox.exceptions.COSVisitorException: java.lang.IndexOutOfBoundsException: Index: 28, Size: 0 at org.apache.pdfbox.pdfwriter.COSWriter.visitFromStream(COSWriter.java:1245) at org.apache.pdfbox.cos.COSStream.accept(COSStream.java:201) at org.apache.pdfbox.cos.COSObject.accept(COSObject.java:206) at org.apache.pdfbox.pdfwriter.COSWriter.doWriteObject(COSWriter.java:524) at org.apache.pdfbox.pdfwriter.COSWriter.doWriteBody(COSWriter.java:434) at org.apache.pdfbox.pdfwriter.COSWriter.visitFromDocument(COSWriter.java:1056) at org.apache.pdfbox.cos.COSDocument.accept(COSDocument.java:496) at org.apache.pdfbox.pdfwriter.COSWriter.write(COSWriter.java:1392) at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1157) at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1138) ... Caused by: java.lang.IndexOutOfBoundsException: Index: 28, Size: 0 at java.util.ArrayList.rangeCheck(ArrayList.java:604) at java.util.ArrayList.get(ArrayList.java:382) at org.apache.pdfbox.io.RandomAccessBuffer.seek(RandomAccessBuffer.java:84) at org.apache.pdfbox.io.RandomAccessFileInputStream.read(RandomAccessFileInputStream.java:96) at java.io.BufferedInputStream.fill(BufferedInputStream.java:235) at java.io.BufferedInputStream.read1(BufferedInputStream.java:275) at java.io.BufferedInputStream.read(BufferedInputStream.java:334) at org.apache.pdfbox.pdfwriter.COSWriter.visitFromStream(COSWriter.java:1232) I'll add some context. We have a "data pipeline" in which a Windows Print Monitor sends postscript into a servlet which then uses GhostScript 9.05 to convert in-memory to PDF. This PDF is then loaded into PDFBox using PDDocument.load(). At this point we split the original PDF into multiple smaller ones each of which is saved to a ByteArrayOutputStream. At the point of save() we are having serious reliability issues. Taking an original PDF from Ghostscript we have saved this into a unit test to replicate the problem without success. If we attempt to re-execute the pipeline to take the original PDF and split it, we get apparently random percentages of saved documents. For instance, on a 990 page document (text, no images), to be split into 990 1-page documents using Tomcat 7 with -Xmx=512m: Pass 1: 50% were saved, 50% ended with stack traces Pass 2: 100% were saved Pass 3: 100% were saved The same test with -Xmx=128m ended several times with just 1 document saved, the rest were stack traces. We have also seen this randomly hit a sample document consisting of four pages to be split into two two-page documents so it does not appear to be memory related. We also added code to catch the IndexOutOfBoundsException and make up to ten attempts to repeat, but it seems the save() either works the first time or not at all. We're thinking there are environmental factors here but we're now focused on getting this nailed. Any advice or assistance will be welcomed.

    Apache's JIRA Issue Tracker | 4 years ago | James Green
    org.apache.pdfbox.exceptions.COSVisitorException: java.lang.IndexOutOfBoundsException: Index: 72, Size: 0
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    [PDFBOX-1625] java.lang.IndexOutOfBoundsException at writing PDF file - ASF JIRA

    apache.org | 1 year ago
    java.io.IOException: org.apache.pdfbox.exceptions.COSVisitorException: java.lang.IndexOutOfBoundsException: Index: 115, Size: 0
  6. 0

    COSVisitorException Exception

    Stack Overflow | 3 years ago | grep
    org.apache.pdfbox.exceptions.COSVisitorException: java.lang.IndexOutOfBoundsException: Index: 1, Size: 0

  1. bmacedo 4 times, last 2 days ago
  2. mhicauber 1 times, last 2 days ago
  3. filpgame 2 times, last 5 days ago
  4. tvrmsmith 1 times, last 6 days ago
  5. Indri Yunita 12 times, last 7 days ago
67 more registered users
28 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.lang.IndexOutOfBoundsException

    Index: 72, Size: 0

    at java.util.ArrayList.RangeCheck()
  2. Java RT
    ArrayList.get
    1. java.util.ArrayList.RangeCheck(ArrayList.java:547)
    2. java.util.ArrayList.get(ArrayList.java:322)
    2 frames
  3. Apache PDFBox
    RandomAccessFileInputStream.read
    1. org.apache.pdfbox.io.RandomAccessBuffer.seek(RandomAccessBuffer.java:84)
    2. org.apache.pdfbox.io.RandomAccessFileInputStream.read(RandomAccessFileInputStream.java:96)
    2 frames
  4. Java RT
    BufferedInputStream.read
    1. java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
    2. java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
    3. java.io.BufferedInputStream.read(BufferedInputStream.java:317)
    3 frames
  5. Apache PDFBox
    PDDocument.save
    1. org.apache.pdfbox.pdfwriter.COSWriter.visitFromStream(COSWriter.java:1337)
    2. org.apache.pdfbox.cos.COSStream.accept(COSStream.java:217)
    3. org.apache.pdfbox.cos.COSObject.accept(COSObject.java:206)
    4. org.apache.pdfbox.pdfwriter.COSWriter.doWriteObject(COSWriter.java:525)
    5. org.apache.pdfbox.pdfwriter.COSWriter.doWriteBody(COSWriter.java:435)
    6. org.apache.pdfbox.pdfwriter.COSWriter.visitFromDocument(COSWriter.java:1122)
    7. org.apache.pdfbox.cos.COSDocument.accept(COSDocument.java:552)
    8. org.apache.pdfbox.pdfwriter.COSWriter.write(COSWriter.java:1501)
    9. org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1324)
    10. org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1305)
    11. org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1292)
    11 frames
  6. com.test
    PdfBoxTest.testPdfBox2
    1. com.test.PdfBoxTest.testPdfBox2(PdfBoxTest.java:77)
    1 frame
  7. Java RT
    Method.invoke
    1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    4. java.lang.reflect.Method.invoke(Method.java:597)
    4 frames
  8. JUnit
    ParentRunner.run
    1. org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    2. org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    3. org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    4. org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    5. org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    6. org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    7. org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    8. org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    9. org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    10. org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    11. org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    12. org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    13. org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    13 frames
  9. JUnit4 Runner
    JUnit4TestReference.run
    1. org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    1 frame
  10. JUnit3 Runner
    RemoteTestRunner.main
    1. org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    2. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    3. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    4. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    5. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
    5 frames