【问题标题】:com.ctc.wstx.exc.WstxParsingException: Text size limitcom.ctc.wstx.exc.WstxParsingException:文本大小限制
【发布时间】:2013-06-21 11:21:36
【问题描述】:

我正在向 CXF 网络服务发送一个大附件,但出现以下异常:

引起:javax.xml.bind.UnmarshalException - 有关联的例外: [com.ctc.wstx.exc.WstxParsingException:超出文本大小限制(134217728) 在 [row,col {unknown-source}]:[1,134855131]] 在 com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:426) 在 com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:362) 在 com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:339) 在 org.apache.cxf.jaxb.JAXBEncoderDecoder.doUnmarshal(JAXBEncoderDecoder.java:769) 在 org.apache.cxf.jaxb.JAXBEncoderDecoder.access 100 美元(JAXBEncoderDecoder.java:94) 在 org.apache.cxf.jaxb.JAXBEncoderDecoder$1.run(JAXBEncoderDecoder.java:797) 在 java.security.AccessController.doPrivileged(本机方法) 在 org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:795) ... 25 更多

问题似乎来自 Woodstox 图书馆,上面写着

超出文本大小限制 (134217728)

有人知道是否可以增加此限制吗?如果是,怎么办?

【问题讨论】:

    标签: web-services configuration cxf woodstox


    【解决方案1】:

    如果它像这样来自woodstox,那么您就不会将其作为MTOM 附件发送。我的第一个建议是将其翻转为 MTOM,以便可以在 XML 解析之外进行处理。效率更高,因为我们可以将其保存为输入流或类似内容,而不是将其保存在内存中。

    如果你想把它保存在 XML 中,你可以将属性:“org.apache.cxf.stax.maxTextLength”设置为更大的值。请记住,像这样从 stax 解析器进来的东西会以 String 或 byte[] 的形式保存在内存中,因此会消耗内存。

    【讨论】:

    • 太棒了!非常感谢。最后一件事,如果我想将属性“org.apache.cxf.stax.maxTextLength”设置为给定值,我应该怎么做?使用系统属性 -Dorg.apache.cxf.stax.maxTextLength=X 可以吗?
    • 使用标准的 Stax 属性机制:XMLInputFactory.setProperty()。此功能是在 Woodstox 4.2 中添加的,以帮助防止拒绝服务攻击:默认值取决于使用 Woodstox 的框架(在本例中为 CXF)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-04
    相关资源
    最近更新 更多