【发布时间】:2020-01-07 19:30:05
【问题描述】:
我有以下代码:
public Object unmarshal(Source source, MimeContainer mimeContainer) throws XmlMappingException {
AttachmentUnmarshaller au = null;
if (this.mtomEnabled && mimeContainer != null) {
au = new MISMarshaller.MISAttachmentUnmarshaller(mimeContainer);
}
if (source instanceof SAXSource && ((SAXSource)source).getXMLReader() != null) {
try {
XMLInputFactory factory = XMLInputFactory.newInstance();
return this.context.unmarshal(au, factory.createXMLStreamReader(source));
} catch (Exception var5) {
throw new UnmarshallingFailureException(var5.getMessage(), var5);
}
} else {
throw new IllegalStateException("Only StAX is supported for MIS marshaller. Use AXIOM message factory.");
}
}
在这一行,我得到一个例外:
return this.context.unmarshal(au, factory.createXMLStreamReader(source));
这是一个例外:
javax.xml.stream.XMLStreamException: 无法创建 Stax 阅读器 源已通过——阅读器、输入流和系统 ID 均未通过 无障碍;不能使用其他类型的源(如嵌入式 SAX 流)
在运行时,source 是 StaxSource 的一个实例。
有没有办法解决这个问题?
【问题讨论】: