0

I'm trying to create a new layout which will be used to create a new slide from the source slide

        XSLFSlideLayout layout;
    try {
        ZipPackagePart zipPackagePart = new ZipPackagePart( srcSlide.getSlideLayout().getPackagePart().getPackage(),
                (new ZipArchiveEntry(srcSlide.getSlideLayout().getPackagePart().getPartName().getURI().toString())),
                PackagingURIHelper.createPartName(srcSlide.getSlideLayout().getPackagePart().getPartName().getURI().toString()),
                srcSlide.getSlideLayout().getPackagePart().getContentType());
        layout  = new XSLFSlideLayout(zipPackagePart);
    } catch (InvalidFormatException | IOException | XmlException e) {
        layout = targetDeck.getSlideMasters().get(0).getLayout(SlideLayout.BLANK);
    }
    XSLFSlide replicaSlide = targetDeck.createSlide(layout);

With the above snippet, I'm seeing an error -

java.lang.ClassCastException: class org.apache.commons.compress.archivers.zip.ZipArchiveEntry cannot be cast to class org.apache.poi.openxml4j.util.ZipArchiveFakeEntry (org.apache.commons.compress.archivers.zip.ZipArchiveEntry and org.apache.poi.openxml4j.util.ZipArchiveFakeEntry are in unnamed module of loader 'app') at org.apache.poi.openxml4j.util.ZipInputStreamZipEntrySource.getInputStream(ZipInputStreamZipEntrySource.java:112) at org.apache.poi.openxml4j.opc.ZipPackagePart.getInputStreamImpl(ZipPackagePart.java:106) at org.apache.poi.openxml4j.opc.PackagePart.getInputStream(PackagePart.java:503) at org.apache.poi.xslf.usermodel.XSLFSlideLayout.(XSLFSlideLayout.java:46)

While org.apache.poi.openxml4j.util.ZipArchiveFakeEntry is inheriting the org.apache.commons.compress.archivers.zip.ZipArchiveEntry. Any suggestions on the issue?

Jatish
  • 352
  • 1
  • 2
  • 10

0 Answers0