New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provider com.bea.xml.stream.EventFactory not found #8

Closed
kurthuwig opened this Issue Feb 11, 2017 · 8 comments

Comments

Projects
None yet
6 participants
@kurthuwig

kurthuwig commented Feb 11, 2017

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)
@centic9

This comment has been minimized.

Owner

centic9 commented Feb 17, 2017

Not sure where the com.bea... part comes from, looks like some other XML parser is found via some service-files in other packaged jars, presumably from some other library that you package into your Android app.

What other dependencies do you have?

@BaN4NaJ0e

This comment has been minimized.

BaN4NaJ0e commented Feb 22, 2017

I am running into exactly the same problem. Here are my dependencies:

dependencies {
apt 'com.google.dagger:dagger-compiler:2.9'
apt "com.github.Raizlabs.DBFlow:dbflow-processor:4.0.0-beta5"
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.github.Raizlabs.DBFlow:dbflow-core:4.0.0-beta5"
compile "com.github.Raizlabs.DBFlow:dbflow:4.0.0-beta5"
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.google.dagger🗡2.9'
compile 'javax.annotation:javax.annotation-api:1.2'
compile 'com.github.tony19:logback-android-core:1.1.1-6'
compile 'com.github.tony19:logback-android-classic:1.1.1-6'
compile 'org.slf4j:slf4j-api:1.7.23'
compile 'org.greenrobot:eventbus:3.0.0'
compile 'com.github.radzio:android-data-binding-recyclerview:0.1.0'
compile 'com.android.support:recyclerview-v7:25.1.1'
compile 'com.android.support:design:25.1.1'
compile 'com.android.support:percent:25.1.1'
debugCompile 'com.facebook.stetho:stetho:1.4.2'
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5'
debugCompile 'com.github.brianPlummer:tinydancer:0.1.1'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
androidTestCompile 'com.android.support:support-annotations:25.1.1'
}

My libs folder only contains the poishadow-all.jar from the release page.

@centic9

This comment has been minimized.

Owner

centic9 commented Feb 24, 2017

I am having a hard time reproducing this with your dependencies as some of them are not publicly available and some clash with the version of Android libs that are used in this sample-project. Can you extract a self-sufficient small sample-app that shows the problem?

@SUPERCILEX

This comment has been minimized.

SUPERCILEX commented Mar 2, 2017

#5 (comment) might fix your issue.

@centic9

This comment has been minimized.

Owner

centic9 commented Mar 8, 2017

I have release version 0.3 which incorporates most of the changes from #7, hopefully this also fixes this issue, please comment and reopen if not.

@centic9 centic9 closed this Mar 8, 2017

@centic9

This comment has been minimized.

Owner

centic9 commented Jun 18, 2017

Please see #10 (comment) in issue #10 where a workaround is described that I also document in the README now until someone comes up with a better way of doing this.

@Xosmond

This comment has been minimized.

Xosmond commented Apr 18, 2018

I went into this problem too, the workaround there not fixed the problem.

package javax.xml.stream;

    public static XMLEventFactory newInstance() throws FactoryConfigurationError {
        return (XMLEventFactory)FactoryFinder.find("javax.xml.stream.XMLEventFactory", "com.bea.xml.stream.EventFactory");
    }

The problem comes from there.

SOLVED WITH:

System.setProperty("javax.xml.stream.XMLInputFactory", "com.fasterxml.aalto.stax.InputFactoryImpl")
System.setProperty("javax.xml.stream.XMLOutputFactory", "com.fasterxml.aalto.stax.OutputFactoryImpl")
System.setProperty("javax.xml.stream.XMLEventFactory", "com.fasterxml.aalto.stax.EventFactoryImpl")

and adding stax to gradle:

implementation 'com.fasterxml:aalto-xml:1.0.0'

@Akansh0581

This comment has been minimized.

Akansh0581 commented Jun 13, 2018

Add the following to your gradle file:
implementation 'com.fasterxml:aalto-xml:1.0.0'
And relax...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment