Bug 58925 - IllegalArgumentException: already added: Lorg/apache/xmlbeans/xml/stream/XMLEvent
Summary: IllegalArgumentException: already added: Lorg/apache/xmlbeans/xml/stream/XMLE...
Status: RESOLVED INVALID
Alias: None
Product: POI
Classification: Unclassified
Component: XWPF (show other bugs)
Version: 3.13-FINAL
Hardware: Other All
: P2 blocker (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on: 59268
Blocks:
  Show dependency tree
 
Reported: 2016-01-27 16:42 UTC by Rowan
Modified: 2016-04-04 07:27 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rowan 2016-01-27 16:42:52 UTC
Integrating POI to Android. 
Referencing poi, poi_ooxml and xml-beans results in Uncaught translation error: java.lang.IllegalArgumentException: already added for multiple classes. Classes of issue are:
1- Lorg/apache/xmlbeans/xml/stream/Location;
2- Lorg/apache/xmlbeans/xml/stream/ReferenceResolver;
3- Lorg/apache/xmlbeans/xml/stream/XMLEvent;
4- Lorg/apache/xmlbeans/xml/stream/XMLInputStream;
5- Lorg/apache/xmlbeans/xml/stream/XMLName;
6- Lorg/apache/xmlbeans/xml/stream/XMLStreamException;
7- Lorg/apache/xmlbeans/xml/stream/utils/NestedThrowable;
8- Lorg/apache/xmlbeans/xml/stream/utils/NestedThrowable$Util;

removing any of the jar files mentioned causes dependency error.

Full log:
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lorg/apache/xmlbeans/xml/stream/Location;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lorg/apache/xmlbeans/xml/stream/ReferenceResolver;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lorg/apache/xmlbeans/xml/stream/XMLEvent;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lorg/apache/xmlbeans/xml/stream/XMLInputStream;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lorg/apache/xmlbeans/xml/stream/XMLName;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lorg/apache/xmlbeans/xml/stream/XMLStreamException;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lorg/apache/xmlbeans/xml/stream/utils/NestedThrowable;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lorg/apache/xmlbeans/xml/stream/utils/NestedThrowable$Util;
8 errors; aborting
Error:Execution failed for task ':app:preDexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_51\bin\java.exe'' finished with non-zero exit value 1
Comment 1 Nick Burch 2016-01-27 16:45:55 UTC
This is an xmlbeans bug, not a POI bug - their 2.6 release jar seems to have some duplicate classes in. You need one of: a fixed xmlbeans jar, a different (earlier) runtime jar, to unpack+repack yourself to remove the duplicates, or to tell your environment to ignore the error
Comment 2 Rowan 2016-01-28 12:59:02 UTC
Thanks for directing me to the right way.
I edited the xml-beans jar and got it to build. Unfortunately, I got a runtime exception of
java.lang.NoClassDefFoundError: Failed resolution of: Ljavax/xml/stream/XMLEventFactory;

Googling it and it seems it takes so many workarounds to get POI to work.
A feature-needed but sadly lot of hacks and workarounds to run.