2

I have a Spring Boot/Maven/Java 8/Tomcat 8.5 webapp which works with docx files. On Mac it works fine, but on Windows i get weird exceptions. I've tried in both environments with the same input data and got different output. On mac I got what I expected, on widows i got only exceptions.

java.lang.ExceptionInInitializerError: null
    at org.apache.poi.openxml4j.opc.internal.ContentTypeManager.parseContentTypesFile(ContentTypeManager.java:392) ~[poi-ooxml-4.0.0.jar:4.0.0]

[...]

Caused by: java.lang.IllegalArgumentException: No attributes are implemented
    at org.apache.crimson.jaxp.DocumentBuilderFactoryImpl.setAttribute(DocumentBuilderFactoryImpl.java:93) ~[crimson-1.1.3.jar:na]
    at org.apache.poi.ooxml.util.DocumentHelper.trySetXercesSecurityManager(DocumentHelper.java:143) ~[poi-ooxml-4.0.0.jar:4.0.0]
    at org.apache.poi.ooxml.util.DocumentHelper.<clinit>(DocumentHelper.java:108) ~[poi-ooxml-4.0.0.jar:4.0.0]
    ... 30 common frames omitted

So, after some search, I've added some values to my catalina.properties. Here the topics already read:

javax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
javax.xml.transform.TransformerFactory=com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl
javax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl

and now the applications seems to work with some inputs, while I'm still getting NullPointers with others. Also a new log is prompted in both cases (java debug enabled).

JAXP: find factoryId =javax.xml.stream.XMLInputFactory
JAXP: loaded from fallback value: com.sun.xml.internal.stream.XMLInputFactoryImpl
JAXP: created new instance of class com.sun.xml.internal.stream.XMLInputFactoryImpl using ClassLoader: null
JAXP: find factoryId =javax.xml.transform.TransformerFactory
JAXP: found system property, value=com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl
JAXP: created new instance of class com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl using ClassLoader: null
JAXP: find factoryId =javax.xml.parsers.DocumentBuilderFactory
JAXP: found system property, value=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
JAXP: created new instance of class com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl using ClassLoader: null

which doesn't seem fine to me.

In my pom i switched from

        <dependency> 
            <groupId>xerces</groupId> 
            <artifactId>xercesImpl</artifactId> 
            <version>2.12.0</version> 
        </dependency> 

to

<dependency>
  <groupId>xerces</groupId>
  <artifactId>xercesImpl</artifactId>
  <version>2.11.0</version>
  <exclusions>
    <exclusion>
      <groupId>xerces</groupId>
      <artifactId>xml-apis</artifactId>
    </exclusion>
  </exclusions>
</dependency>

with no changes.

What's happening?

Thanks for your help.

JasonPlutext
  • 15,352
  • 4
  • 44
  • 84
mgu
  • 67
  • 1
  • 7

0 Answers0