Richard C
Richard C

Reputation: 41

Apache POI issue TransformerFactory does not recognise attribute

An exception is being thrown after calling Apache POI's POIXMLDocument.write() method. I tried both IcedTea and OpenJDK java 8 with the same results. Below is th stack trace. Any help will be appreciated!

[org.apache.poi.util.XMLHelper]W SAX Feature unsupported [log suppressed for 5 minutes]http://javax.xml.XMLConstants/property/accessExternalSchema java.lang.IllegalArgumentException: TransformerFactory does not recognise attribute 'http://javax.xml.XMLConstants/property/accessExternalSchema'. at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.setAttribute(TransformerFactoryImpl.java:471) at org.apache.poi.util.XMLHelper.trySet(XMLHelper.java:280) at org.apache.poi.util.XMLHelper.getTransformerFactory(XMLHelper.java:222) at org.apache.poi.util.XMLHelper.newTransformer(XMLHelper.java:227) at org.apache.poi.openxml4j.opc.StreamHelper.saveXmlInStream(StreamHelper.java:56) at org.apache.poi.openxml4j.opc.internal.ZipContentTypeManager.saveImpl(ZipContentTypeManager.java:69) at org.apache.poi.openxml4j.opc.internal.ContentTypeManager.save(ContentTypeManager.java:452) at org.apache.poi.openxml4j.opc.ZipPackage.saveImpl(ZipPackage.java:520) at org.apache.poi.openxml4j.opc.OPCPackage.save(OPCPackage.java:1514) at org.apache.poi.ooxml.POIXMLDocument.write(POIXMLDocument.java:227)

Upvotes: 4

Views: 7857

Answers (2)

MarkUs
MarkUs

Reputation: 171

A solution that worked for me (just blocks the WARN msg from being output):

//  block poi 5.1.0 outputting '... accessExternalSchema' WARN msg
// (https://bz.apache.org/bugzilla/show_bug.cgi?id=65326)

    static { 
        org.apache.logging.log4j.core.config.Configurator.setLevel("org.apache.poi.util.XMLHelper", Level.ERROR);
    }

    :
    Workbook workbook = WorkbookFactory.create(excelFile, null, true);    
    :

Upvotes: 2

Richard C
Richard C

Reputation: 41

I fixed it.

For some reason if I call System.setProperty("org.apache.poi.util.POILogger", "org.apache.poi.util.SystemOutLogger" ); before trying to write the document, it fails. I removed that (old) line of code and now everything is working fine.

Upvotes: 0

Related Questions