poi-on-android: Provider com.bea.xml.stream.EventFactory not found
I try to read an xlsx file from an InputStream
workbook = new XSSFWorkbook(is);
which yields
org.apache.poi.javax.xml.stream.FactoryConfigurationError: Provider com.bea.xml.stream.EventFactory not found
at org.apache.poi.javax.xml.stream.FactoryFinder.newInstance(FactoryFinder.java:72)
at org.apache.poi.javax.xml.stream.FactoryFinder.find(FactoryFinder.java:178)
at org.apache.poi.javax.xml.stream.FactoryFinder.find(FactoryFinder.java:92)
at org.apache.poi.javax.xml.stream.XMLEventFactory.newInstance(XMLEventFactory.java:30)
at org.apache.poi.openxml4j.opc.internal.marshallers.PackagePropertiesMarshaller.<clinit>(PackagePropertiesMarshaller.java:41)
at org.apache.poi.openxml4j.opc.OPCPackage.init(OPCPackage.java:161)
at org.apache.poi.openxml4j.opc.OPCPackage.<init>(OPCPackage.java:141)
at org.apache.poi.openxml4j.opc.ZipPackage.<init>(ZipPackage.java:96)
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:342)
at org.apache.poi.util.PackageHelper.open(PackageHelper.java:37)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:285)
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 21 (8 by maintainers)
I went into this problem too, the workaround there not fixed the problem.
package javax.xml.stream;
The problem comes from there.
SOLVED WITH:
and adding stax to gradle:
implementation 'com.fasterxml:aalto-xml:1.0.0'
Add the following to your gradle file: implementation ‘com.fasterxml:aalto-xml:1.0.0’ And relax…
Woops, my apologies, I copied the wrong lines from my code. I have updated my post to be the correct lines. All together, this is the full set I needed to get it working:
Add them in onCreate function of Main Activity
Strange that you needed them for the “javax.xml.stream” package as well as we shade all code underneath org.apache.poi here and javax.xml.stream should not exist at all.
Do you have a stacktrace where exactly in the code this was causing an Exception?
Hm, these are exactly the lines mentioned in the README already, so I don’t see what can be updated there?
The addition of com.fasterxml should not be necessary and is the cause for the duplicates.
I would check if the setProperty calls are really executed before you reach any Apache POI code and if the error is really exactly the one that was discussed in this issue.