zoukankan      html  css  js  c++  java
  • SAXException Parser configuration problem: namespace reporting is not enabled

    问题描述:

    用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);

    像这样即可修复。

  • 相关阅读:
    【nodejs】使用Node.js实现REST Client调用REST API
    [Groovy] Groovy && JNI
    一些很实用的Maven Plugins
    秋天到了
    今天头好疼
    想起那个人的时候
    不知道标题
    生活让我懂得
    显示实现接口和实现接口
    Foreach原理
  • 原文地址:https://www.cnblogs.com/simoncook/p/7920882.html
Copyright © 2011-2022 走看看