Java 本地部分不能为“0”;空";创建QName时
我们正在努力追踪一个bug。我们在日志中得到了上述错误 有人能解释一下这个信息的含义吗?收到这条消息有什么典型的原因吗 堆栈跟踪是:Java 本地部分不能为“0”;空";创建QName时,java,websphere,Java,Websphere,我们正在努力追踪一个bug。我们在日志中得到了上述错误 有人能解释一下这个信息的含义吗?收到这条消息有什么典型的原因吗 堆栈跟踪是: org.apache.axiom.om.OMException: java.lang.IllegalArgumentException: local part cannot be "null" when creating a QName at org.apache.axiom.om.impl.builder.StAXOMBuilder.ne
org.apache.axiom.om.OMException: java.lang.IllegalArgumentException: local part cannot be "null" when creating a QName
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:206)
at org.apache.axiom.om.impl.llom.OMNodeImpl.build(OMNodeImpl.java:318)
at org.apache.axiom.om.impl.llom.OMElementImpl.build(OMElementImpl.java:618)
at org.apache.axis2.jaxws.message.util.impl.SAAJConverterImpl.toOM(SAAJConverterImpl.java:147)
at org.apache.axis2.jaxws.message.impl.XMLPartImpl._convertSE2OM(XMLPartImpl.java:77)
at org.apache.axis2.jaxws.message.impl.XMLPartBase.getContentAsOMElement(XMLPartBase.java:203)
at org.apache.axis2.jaxws.message.impl.XMLPartBase.getAsOMElement(XMLPartBase.java:255)
at org.apache.axis2.jaxws.message.impl.MessageImpl.getAsOMElement(MessageImpl.java:464)
at org.apache.axis2.jaxws.message.util.MessageUtils.putMessageOnMessageContext(MessageUtils.java:202)
at org.apache.axis2.jaxws.core.controller.AxisInvocationController.prepareRequest(AxisInvocationController.java:370)
at org.apache.axis2.jaxws.core.controller.InvocationController.invoke(InvocationController.java:120)
at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invokeSEIMethod(JAXWSProxyHandler.java:317)
at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invoke(JAXWSProxyHandler.java:148)
这意味着您正在使用这样的名称空间方法之一创建DOM元素或属性 或
createElements
或setAttrbuteNS
第二个参数,qname是null
,或者包含前缀,但没有本地部分,如“foo:”
编辑:
我会尝试通过验证器运行它正在解析的XML。很可能有一些标记或属性名,如
foo:
或foo:bar:baz
,是有效的XML标识符,但根据XML名称空间引入的附加限制无效。虽然这是一个旧线程,但我希望这个答案能够帮助其他人搜索此错误。
当我尝试使用maven Enouncate cxf插件1.28构建web应用程序时,我也遇到了同样的错误
对我来说,这是在我向我的web服务签名添加了一个选中的异常后造成的:
@WebMethod(operationName = "enquirySth")
public IBANResponse enquirySth(String input) throws I
InvalidInputException { ...
我使用了异常抛出,但没有成功。最后,我在Enounciate issue tracker system中发现,这表明该问题在当前版本中已得到解决,但我认为它仍然存在
最后,我完成了以下解决方法来解决我的问题:
将@XmlRootElement添加到我的FaultBean中
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "FaultBean",propOrder = {"errorDescription", "errorCode"})
public class FaultBean implements Serializable {
@XmlElement(required = true, nillable = true)
protected String errorDescription;
@XmlElement(required = true, nillable = true)
protected String errorCode;
public FaultBean() {
}
public String getErrorDescription() {
return this.errorDescription;
}
public void setErrorDescription(String var1) {
this.errorDescription = var1;
}
public String getErrorCode() {
return this.errorCode;
}
public void setErrorCode(String var1) {
this.errorCode = var1;
}
}
就这样。希望有帮助。我在尝试从字符串构造org.w3c.dom.Document时收到了相同的错误消息(创建QName时,本地部分不能为“null”)。在DocumentBuilderFactory上调用setNamespaceAware(true)后,问题消失了。下面给出了工作代码片段
private static Document getDocumentFromString(final String xmlContent)
throws Exception
{
DocumentBuilderFactory documentBuilderFactory =
DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true);
try
{
return documentBuilderFactory
.newDocumentBuilder()
.parse(new InputSource(new StringReader(xmlContent)));
}
catch (Exception e)
{
throw new RuntimeException(e);
}
}
stacktrace可能会帮助人们,如果您有one@BruceLowe,谢谢你的评论,我加了一个谢谢你的回复,我加了一个stacktrace
private static Document getDocumentFromString(final String xmlContent)
throws Exception
{
DocumentBuilderFactory documentBuilderFactory =
DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true);
try
{
return documentBuilderFactory
.newDocumentBuilder()
.parse(new InputSource(new StringReader(xmlContent)));
}
catch (Exception e)
{
throw new RuntimeException(e);
}
}