问题描述:

用sax的方式组装xml,在tomcat上正常运行,在weblogic12c上报错:

SAXException Parser configuration problem: namespace reporting is not enabled

JDK都是用的1.8

 

搜索,

发现SAXException Parser configuration problem: namespace reporting is not enabled来自 saxon jar包中的错误

 

找到代码:

// net.sf.saxon.event.ReceivingContentHandler

// It's also possible (especially when using a TransformerHandler) that the parser
        // has been configured to report the QName rather than the localname+URI
        if (localname.length() == 0) {
            throw new SAXException("Parser configuration problem: namespace reporting is not enabled");
        }

分析

通过

System.setProperty("javax.xml.transform.TransformerFactory",
                "net.sf.saxon.TransformerFactoryImpl");

即指定了SAXTransformerFactory的实现方式,便可以在单元测试时重现。

 

修复

在sax中做write时要指定localname,不能空着。

handler.startElement("", ROOT_ELEMENT_NAME, ROOT_ELEMENT_NAME, atts);

像这样即可修复。

相关文章:

  • 2021-09-24
  • 2021-04-18
  • 2022-12-23
  • 2022-01-16
  • 2021-10-19
  • 2021-10-12
  • 2022-12-23
  • 2021-11-12
猜你喜欢
  • 2022-12-23
  • 2021-08-03
  • 2021-08-20
  • 2021-11-30
  • 2021-10-13
相关资源
相似解决方案