OK, apologies for the spam. I'm doing this work for a client, and in an attempt to minimize billable hours I was sending to the list hoping folks might short-circuit some of my trial-and-error. :)
I realized that the implementation didn't need to include newFactory, assuming there would be an implementation in the abstract superclass. That must have been correct. After selecting and installing the 4.4.1 Woodstox implementation, keeping a bunch of classes via Proguard, excluding the hssf package/subpackage to avoid the Dalvik method limit and keeping the schemas, I've hit this error: E/AndroidRuntime( 2764): Caused by: java.lang.ClassCastException: org.apache.xmlbeans.impl.values.XmlComplexContentImpl cannot be cast to org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDocument1 E/AndroidRuntime( 2764): at org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDocument1$Factory.newInstance(Unknown Source) E/AndroidRuntime( 2764): at org.apache.poi.xwpf.usermodel.XWPFDocument.onDocumentCreate(XWPFDocument.java:277) E/AndroidRuntime( 2764): at org.apache.poi.xwpf.usermodel.XWPFDocument.<init>(XWPFDocument.java:130) ... Any idea what might be causing this? If the solution isn't simple or if there isn't an obvious path to take, I'd be interested in any commercial options I might refer to my client. If anyone can recommend someone, please do let me know. Thanks! On 10/13/2014 1:43 PM, Nolan Darilek wrote: > Ugh, this is very hard to sort out, you're right. > > So I actually got the correct API dependency a few hours ago, using: > > "javax.xml.parsers:jaxp-api:1.4.5" > > Now the issue I'm running into is lack of an implementation. Basically > I'm downloading jars from Maven, unzipping them, running the > XMLEventFactoryImpl.class file found therein through javap and searching > for newFactory. I just looked at xerces:xercesImpl:2.11.0 and it misses > this method. > > I'll keep looking, but would anyone be so kind as to point me to a > working implementation independent of the JDK that includes newFactory? > I've found documentation on tweaking the Android class loader and system > properties to point to the new factories, so hopefully once I find and > drop in a compatible implementation I'll be set. I fully intend to blog > the solution once I've found it, since thus far I'm manipulating > dependencies fresh from the source with jarjar and am not repackaging > them manually as some solutions seem to advocate. > > Thanks for pointing me in the right direction. I've been hacking away at > this both with POI and Docx4J for almost a week and have hit just about > every issue you're likely to encounter. :) > > On 10/13/2014 1:01 PM, Dominik Stadler wrote: >> Yes, such dependencies are always hard to sort out. >> >> The geronimo-stax-api_1.2 jar seems to have it, see >> http://search.maven.org/#artifactdetails|org.apache.geronimo.specs|geronimo-stax-api_1.2_spec|1.2|bundle >> >> Dominik. >> >> On Mon, Oct 13, 2014 at 6:32 PM, Nolan Darilek <[email protected]> >> wrote: >>> Hmm, you're right. I looked at some version of XMLEventFactory with >>> javap and could have sworn I'd seen the >>> newFactory method, but I can't find that version now, and the versions I >>> have found don't include newFactory. >>> >>> Where might I find an implementation that includes newFactory if I can't >>> count on my VM shipping it (I.e. Dalvik?) I tried stax:stax:1.2.0 but it >>> doesn't seem to ship with a set of javax classes--at least, I can't find >>> one in Gradle's build directory. There is of course a stax 1.0.1 that >>> doesn't include newFactory. >>> >>> Thanks. >>> >>> On 10/12/2014 1:46 PM, Dominik Stadler wrote: >>>> Hi, >>>> >>>> This sounds like you are using an older version of class >>>> XMLEventFactory from somewhere, it probably is pulled in by >>>> stax-api.jar or an outdated xml-apis.jar, the classes in JDK 6 or >>>> higher have the method newFactory(), while older ones seem to miss it. >>>> >>>> Dominik. >>>> >>>> On Sun, Oct 12, 2014 at 4:11 AM, Nolan Darilek <[email protected]> >>>> wrote: >>>>> Hello, >>>>> >>>>> I'm having a very hard time trying to use XWPFDocument on Android. Seems >>>>> like I've read everything I can find from Google on the subject, but am >>>>> still hitting an issue. In particular, here's part of the exception I'm >>>>> getting when I try to write a DocX from an Android app: >>>>> >>>>> E/AndroidRuntime( 2553): java.lang.NoSuchMethodError: >>>>> avax.xml.stream.XMLEventFactory.newFactory >>>>> >>>>> E/AndroidRuntime( 2553): at >>>>> org.apache.poi.openxml4j.opc.internal.marshallers.PackagePropertiesMarshaller.<clinit>(PackagePropertiesMarshaller.java:45) >>>>> >>>>> E/AndroidRuntime( 2553): at >>>>> org.apache.poi.openxml4j.opc.OPCPackage.init(OPCPackage.java:161) >>>>> >>>>> E/AndroidRuntime( 2553): at >>>>> org.apache.poi.openxml4j.opc.OPCPackage.<init>(OPCPackage.java:141) >>>>> >>>>> E/AndroidRuntime( 2553): at >>>>> org.apache.poi.openxml4j.opc.Package.<init>(Package.java:37) >>>>> >>>>> E/AndroidRuntime( 2553): at >>>>> org.apache.poi.openxml4j.opc.ZipPackage.<init>(ZipPackage.java:65) >>>>> >>>>> E/AndroidRuntime( 2553): at >>>>> org.apache.poi.openxml4j.opc.OPCPackage.create(OPCPackage.java:337) >>>>> >>>>> E/AndroidRuntime( 2553): at >>>>> org.apache.poi.xwpf.usermodel.XWPFDocument.newPackage(XWPFDocument.java:256) >>>>> >>>>> E/AndroidRuntime( 2553): at >>>>> org.apache.poi.xwpf.usermodel.XWPFDocument.<init>(XWPFDocument.java:129) >>>>> >>>>> I understand the issues on Android are 2-fold. 1: the method limit. I >>>>> haven't seemed to hit that yet, so I haven't needed to shrink the POI >>>>> jars. >>>>> >>>>> 2. The use of javax.* namespaces. Many of the solutions I saw on Google >>>>> involved manually opening the jars and replacing "javax" with something >>>>> else, like "avax". For this I used Jarjar and the Gradle plugin for >>>>> same, with a rule like: >>>>> >>>>> "rule javax.** avax.@1" >>>>> >>>>> The resulting fat jar appears to have its javax namespace renamed, and >>>>> indeed, I can't find the string "javax" anywhere when grepping through >>>>> the directories. >>>>> >>>>> I'm also not sure if I need to manually install stax-api. It appears to >>>>> be installed as a POI dependency, but installing stax:stax-api:1.0.1 >>>>> doesn't seem to make much of a difference. >>>>> >>>>> Any idea as to why I'm getting this NoSuchMethodError? Guessing it has >>>>> to be something found on the JVM but not Dalvik, but I can't figure out >>>>> what that is and am quickly approaching my wits' end. Do I have to do >>>>> anything to tell POI to use the javax.xml.* facilities provided by >>>>> stax-api and not expect to find them on the VM running it? Or is there >>>>> something else I'm missing? >>>>> >>>>> Thanks. >>>>> >>>>> --------------------------------------------------------------------- >>>>> To unsubscribe, e-mail: [email protected] >>>>> For additional commands, e-mail: [email protected] >>>>> >>>> --------------------------------------------------------------------- >>>> To unsubscribe, e-mail: [email protected] >>>> For additional commands, e-mail: [email protected] >>>> >>>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: [email protected] >>> For additional commands, e-mail: [email protected] >>> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [email protected] >> For additional commands, e-mail: [email protected] >> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
