PDF MERGE ISSUE (java.lang.ClassCastException)

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF Merger for Java (v6)  /  PDF MERGE ISSUE (java.lang.ClassCastException)

DynamicPDF Merger for Java (v6) Forum

We have a PDF file that is merged with dynamic data at run time using Dynamic PDF. We have been working with Dynamic PDF merger from quite some time and it was working fine but recently we are getting the below error that looks very strange.
This error is received intermittently.
Also there is no code changes done at our side,please help analyze the reason.

java.lang.ClassCastException: com.cete.dynamicpdf.merger.yc cannot be cast to java.lang.Comparable

       at java.util.ComparableTimSort.countRunAndMakeAscending(ComparableTimSort.java:320)
       at java.util.ComparableTimSort.sort(ComparableTimSort.java:202)
       at java.util.Arrays.sort(Arrays.java:1246)
       at com.cete.dynamicpdf.ec.drawStructureTreeRoot(Unknown Source)
       at com.cete.dynamicpdf.ec.draw(Unknown Source)
       at com.cete.dynamicpdf.io.DocumentResourceList.a(Unknown Source)
       at com.cete.dynamicpdf.io.n.draw(Unknown Source)
       at com.cete.dynamicpdf.Document.draw(Unknown Source)
       at com.cete.dynamicpdf.Document.draw(Unknown Source)
       at com.forms.PdfProviderDynamicPdf.merge(PdfProviderDynamicPdf.java:172)
       at com.forms.PdfProviderDynamicPdf.merge(PdfProviderDynamicPdf.java:190)
       at com.forms.PdfProviderDynamicPdf.merge(PdfProviderDynamicPdf.java:157)
       at com.forms.PdfProviderDynamicPdf.testMerge(PdfProviderDynamicPdf.java:264)


java code:
  public File merge(List<File> files) throws IOException {
    if (files.size() == 1) {
      return files.get(0);
    }
    /*
     * Uses binary merge to reduce intermediate file sizes
     */
    List<File> subList1 = files.subList(0, files.size() / 2);
    List<File> subList2 = files.subList(files.size() / 2, files.size());
    return merge(subList1, subList2);
  }

  private File merge(List<File> list1, List<File> list2) throws IOException {
    if (list1.size() == 1 && list2.size() == 1) {
      return merge(list1.get(0).getCanonicalPath(), list2.get(0).getCanonicalPath());
    }
    if (list1.size() == 1) {
      List<File> subList1 = list2.subList(0, list2.size() / 2);
      List<File> subList2 = list2.subList(list2.size() / 2, list2.size());

      return merge(list1.get(0).getCanonicalPath(), merge(subList1, subList2).getCanonicalPath());
    } else if (list2.size() == 1) {
      List<File> subList1 = list1.subList(0, list1.size() / 2);
      List<File> subList2 = list1.subList(list1.size() / 2, list1.size());

      return merge(merge(subList1, subList2).getCanonicalPath(), list2.get(0).getCanonicalPath());
    } else {
      List<File> subList1 = list1.subList(0, list1.size() / 2);
      List<File> subList2 = list1.subList(list1.size() / 2, list1.size());

      List<File> subList3 = list2.subList(0, list2.size() / 2);
      List<File> subList4 = list2.subList(list2.size() / 2, list2.size());

      return merge(merge(subList1, subList2).getCanonicalPath(), merge(subList3, subList4)
          .getCanonicalPath());
    }
  }

private File merge(String s1, String s2) throws IOException {
         
    MergeDocument mergeDocument = MergeDocument.merge(s1, s2);
    File file = File.createTempFile("forms", ".pdf");
    mergeDocument.draw(file.getCanonicalPath());
    return file;
}

Maven dependency:
        <dependency>
                        <groupId>com.cete</groupId>
                        <artifactId>dynamic-pdf</artifactId>
                        <version>6.0.0</version>
                </dependency>


Posted by a ceTe Software moderator
Hi,

Please send over following information to support@dynamicpdf.com so we can look into it further.

1. Source PDF using which you are getting error.
2. Simple code sample which uses static data to recreate the error.
3. Exact version and build number of the DynamicPDF jar file used in your application.
4. Full error message along with stack trace.

Thanks,
ceTe Software Support Team

All times are US Eastern Standard time. The time now is 10:23 AM.