简体   繁体   中英

InputStream of class class org.apache.commons.compress.archivers.zip.ZipFile$1 is not implementing InputStreamStatistics

I have just migrated my libraries so that my code is now using the new Apache POI5.0 instead of POI4.12. I am using POI to build an Excel file from scratch with data retrieved from my database. The code was working fine but now, when my code is writing the contents, I receive an exception. I am using commons-compress-1.20 which is the library released with Apache POI5.0.

[err] java.lang.IllegalArgumentException: InputStream of class class org.apache.commons.compress.archivers.zip.ZipFile$1 is not implementing InputStreamStatistics.
[err]   at org.apache.poi.openxml4j.util.ZipArchiveThresholdInputStream.<init>(ZipArchiveThresholdInputStream.java:65)
[err]   at [internal classes]

Any ideas? Thanks in advance.

There are several reasons this could be happening, as mentioned in the comments.

There could be a version conflict. Specifically you have version <= 1.6 of Apache commons-compress alongside >= 5 of Apache POI which are not compatible. To solve this, you will need to change your classpath - if you're using Maven then use mvn dependency:tree and if Gradle then use gradle dependencies .

You don't know where the call to the constructor is coming from because (probably) the application server Liberty is removing some of them. You can get the full stacktrace from messages.log and then you can see the full cause which could poentially be another class calling the ZipArchiveThresholdInputStream constructor with another InputStream that doesn't implement InputStreamStatistics . I would guess that this is less likely than the simple version conflict mentioned above.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM