本文介绍了类org.apache.commons.compress.archivers.zip.ZipFile $ 1的flink InputStream没有实现InputStreamStatistics的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Flink程序中将Excel加载到POI工作簿中.出现这样的错误.

I was trying to load an excel into POI workbook in a Flink program. Has an error like this.

原因:java.lang.IllegalArgumentException:类org.apache.commons.compress.archivers.zip.ZipFile $ 1的InputStream没有实现InputStreamStatistics. 在org.apache.poi.openxml4j.util.ZipArchiveThresholdInputStream.(ZipArchiveThresholdInputStream.java:63) 在org.apache.poi.openxml4j.util.ZipSecureFile.getInputStream(ZipSecureFile.java:147) 在org.apache.poi.openxml4j.util.ZipSecureFile.getInputStream(ZipSecureFile.java:34) 在org.apache.poi.openxml4j.util.ZipFileZipEntrySource.getInputStream(ZipFileZipEntrySource.java:66) 在org.apache.poi.openxml4j.opc.ZipPackage.getPartsImpl(ZipPackage.java:258) 在org.apache.poi.openxml4j.opc.OPCPackage.getParts(OPCPackage.java:725) 在org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:275) 在org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:181) 在org.apache.poi.xssf.usermodel.XSSFWorkbook.(XSSFWorkbook.java:323)

Caused by: java.lang.IllegalArgumentException: InputStream of class class org.apache.commons.compress.archivers.zip.ZipFile$1 is not implementing InputStreamStatistics. at org.apache.poi.openxml4j.util.ZipArchiveThresholdInputStream.(ZipArchiveThresholdInputStream.java:63) at org.apache.poi.openxml4j.util.ZipSecureFile.getInputStream(ZipSecureFile.java:147) at org.apache.poi.openxml4j.util.ZipSecureFile.getInputStream(ZipSecureFile.java:34) at org.apache.poi.openxml4j.util.ZipFileZipEntrySource.getInputStream(ZipFileZipEntrySource.java:66) at org.apache.poi.openxml4j.opc.ZipPackage.getPartsImpl(ZipPackage.java:258) at org.apache.poi.openxml4j.opc.OPCPackage.getParts(OPCPackage.java:725) at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:275) at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:181) at org.apache.poi.xssf.usermodel.XSSFWorkbook.(XSSFWorkbook.java:323)

通知测试 https://github.com/apache/poi/blob/f509d1deae86866ed531f10f2eba7db17e098473/src/ooxml/testcases/org/apache/poi/openxml4j/util/TestZipSecureFile.java 在此提及.但是如何解决它.谢谢!

notice a test https://github.com/apache/poi/blob/f509d1deae86866ed531f10f2eba7db17e098473/src/ooxml/testcases/org/apache/poi/openxml4j/util/TestZipSecureFile.java here that mention this. But how to work around it. Thanks!

推荐答案

您必须包括一个较新版本的commons-compress并对其进行阴影处理(Maven,Gradle和SBT中有不同的插件).或者,您可以使用具有本地Flink支持的HadoopOffice库来读取/写入Excel文件( https://github.com/zuinnote/hadoopoffice/wiki ),并提供了有关如何正确隐藏依赖项的示例(请参见 https://github.com/ZuInnoTe/hadoopoffice/wiki/使用Apache-Flink-to-read-write-Excel-文档)

You have to include a newer version of commons-compress and shade it (there ar different plugins in Maven, Gradle, SBT). Alternatively, you can use the HadoopOffice library, which has native Flink support, to read/write Excel files (https://github.com/zuinnote/hadoopoffice/wiki) and it has an example on how to shade the dependency correctly (see https://github.com/ZuInnoTe/hadoopoffice/wiki/Using-Apache-Flink-to-read-write-Excel-documents)

这篇关于类org.apache.commons.compress.archivers.zip.ZipFile $ 1的flink InputStream没有实现InputStreamStatistics的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 08:02