类org.apache.commons.compress.archivers.zip.ZipFile $ 1的flink InputStream没有实现InputStreamStatistics

时间:2018-09-23 15:01:17

标签: excel scala apache-poi apache-flink

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

原因: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)

请注意此处的测试https://github.com/apache/poi/blob/f509d1deae86866ed531f10f2eba7db17e098473/src/ooxml/testcases/org/apache/poi/openxml4j/util/TestZipSecureFile.java。但是如何解决它。谢谢!

1 个答案:

答案 0 :(得分:0)

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