Skip to content
This repository has been archived by the owner on Nov 20, 2022. It is now read-only.

UnitTest: Provider for class javax.xml.stream.XMLInputFactory cannot be created #13

Open
omensight opened this issue Feb 10, 2021 · 0 comments

Comments

@omensight
Copy link

Hi, I am getting thit error in unit testing, even when I am not using POI in that test:
`javax.xml.stream.FactoryConfigurationError: Provider for class javax.xml.stream.XMLInputFactory cannot be created

at java.xml/javax.xml.stream.FactoryFinder.findServiceProvider(FactoryFinder.java:371)
at java.xml/javax.xml.stream.FactoryFinder.find(FactoryFinder.java:314)
at java.xml/javax.xml.stream.FactoryFinder.find(FactoryFinder.java:227)
at java.xml/javax.xml.stream.XMLInputFactory.newFactory(XMLInputFactory.java:225)
at org.robolectric.res.StaxDocumentLoader.(StaxDocumentLoader.java:22)
at org.robolectric.res.ResourceTableFactory.parseResourceFiles(ResourceTableFactory.java:122)
at org.robolectric.res.ResourceTableFactory.lambda$newFrameworkResourceTable$0(ResourceTableFactory.java:27)
at org.robolectric.util.PerfStatsCollector.measure(PerfStatsCollector.java:53)
at org.robolectric.res.ResourceTableFactory.newFrameworkResourceTable(ResourceTableFactory.java:13)
at org.robolectric.android.internal.AndroidTestEnvironment.getSystemResourceTable(AndroidTestEnvironment.java:334)
at org.robolectric.android.internal.AndroidTestEnvironment.injectResourceStuffForLegacy(AndroidTestEnvironment.java:360)
at org.robolectric.android.internal.AndroidTestEnvironment.loadAppPackage_measured(AndroidTestEnvironment.java:303)
at org.robolectric.android.internal.AndroidTestEnvironment.lambda$loadAppPackage$1(AndroidTestEnvironment.java:296)
at org.robolectric.util.PerfStatsCollector.measure(PerfStatsCollector.java:53)
at org.robolectric.android.internal.AndroidTestEnvironment.loadAppPackage(AndroidTestEnvironment.java:294)
at org.robolectric.android.internal.AndroidTestEnvironment.installAndCreateApplication(AndroidTestEnvironment.java:195)
at org.robolectric.android.internal.AndroidTestEnvironment.setUpApplicationState(AndroidTestEnvironment.java:171)
at org.robolectric.RobolectricTestRunner.beforeTest(RobolectricTestRunner.java:319)
at org.robolectric.internal.SandboxTestRunner$2.lambda$evaluate$0(SandboxTestRunner.java:269)
at org.robolectric.internal.bytecode.Sandbox.lambda$runOnMainThread$0(Sandbox.java:89)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.base/java.lang.Thread.run(Thread.java:844)
Caused by: java.lang.RuntimeException: Provider for class javax.xml.stream.XMLInputFactory cannot be created at java.xml/javax.xml.stream.FactoryFinder.findServiceProvider(FactoryFinder.java:368) ... 23 more Caused by: java.util.ServiceConfigurationError: javax.xml.stream.XMLInputFactory: com.fasterxml.aalto.stax.InputFactoryImpl not a subtype at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:588) at java.base/java.util.ServiceLoader.access$200(ServiceLoader.java:390) at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNextService(ServiceLoader.java:1231) at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNext(ServiceLoader.java:1259) at java.base/java.util.ServiceLoader$2.hasNext(ServiceLoader.java:1294) at java.base/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1379) at java.xml/javax.xml.stream.FactoryFinder$1.run(FactoryFinder.java:353) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.xml/javax.xml.stream.FactoryFinder.findServiceProvider(FactoryFinder.java:342) ... 23 more`

When I am using that in android runtime, it works very well using the next property definitions:
System.setProperty("org.apache.poi.javax.xml.stream.XMLInputFactory", "com.fasterxml.aalto.stax.InputFactoryImpl"); System.setProperty("org.apache.poi.javax.xml.stream.XMLOutputFactory", "com.fasterxml.aalto.stax.OutputFactoryImpl"); System.setProperty("org.apache.poi.javax.xml.stream.XMLEventFactory", "com.fasterxml.aalto.stax.EventFactoryImpl");

But I can't define them in unit testing.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant