Bug 57622

Summary: 3.11 new call to XMLEventFactory.newFactory() introduces incompatibility with IBM WAS 7 (IBM 1.6 JDK)
Product: POI Reporter: David <mediocaballero.spam>
Component: POI OverallAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 3.11-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: Linux   

Description David 2015-02-23 12:12:03 UTC
Hi!

At work we were making use of POI and when we updated the version to 3.11 we suffered some incompatibility issues. We have IBM WAS 7 servers and are unable to migrate (easily to WAS 8.5.5). IBMs JDK 1.6 implementation doesn't include all stax related classes and methods. Namely, we had an issue with POI class 
PackagePropertiesMarshaller.java, where it includes:

  static
  {
    XMLEventFactory f = XMLEventFactory.newFactory();
    namespaceDC = f.createNamespace("dc", "http://purl.org/dc/elements/1.1/");
    namespaceCoreProperties = f.createNamespace("cp", "http://schemas.openxmlformats.org/package/2006/metadata/core-properties");
    namespaceDcTerms = f.createNamespace("dcterms", "http://purl.org/dc/terms/");
    namespaceXSI = f.createNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
  }

IBM implementation has newInstance(), but not newFactory (in Oracle's JVM, it was introduced in 1.6 fix 18)

We have had to change PackagePropertiesMarshaller.java to use newInstance, so it could keep on running in our servers:

  static
  {
    XMLEventFactory f = XMLEventFactory.newInstance();
    namespaceDC = f.createNamespace("dc", "http://purl.org/dc/elements/1.1/");
    namespaceCoreProperties = f.createNamespace("cp", "http://schemas.openxmlformats.org/package/2006/metadata/core-properties");
    namespaceDcTerms = f.createNamespace("dcterms", "http://purl.org/dc/terms/");
    namespaceXSI = f.createNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
  }

As the resultin execution is the same, to mantain compatibility with the broadest range of servers, I'd suggest to change this particular call.
Comment 1 Nick Burch 2015-02-23 14:03:23 UTC
Do all unit tests still pass on an Orcale JVM after the change?

(We don't want to make the change and break things on other JVMs!)
Comment 2 David 2015-02-23 16:31:13 UTC
I haven't been able to test it, but according to API spec, it shouldn't have any effect.

newInstance existed since first version of stax api, while newFactoy was introduced in Oracle 1.6.0.18 'to mantain api consistency', but both have the same functionality.

http://docs.oracle.com/javase/6/docs/api/javax/xml/stream/XMLEventFactory.html#newInstance(java.lang.String, java.lang.ClassLoader)

http://upstream.rosalinux.ru/java/compat_reports/jdk/1.6.0.17_to_1.6.0.18/bin_compat_report.html#Added

Also as a reference, other users with the same issue:
http://mail-archives.apache.org/mod_mbox/poi-dev/201501.mbox/%3CFB8F943CCE197F4A8C65545509CA885B0180A24F7FD8@MSGRTPCCRF2WIN.DMN1.FMR.COM%3E
Comment 3 Nick Burch 2015-02-24 12:04:37 UTC
Changed in r1661903, thanks for your investigations and help on this!