如何修复我的“流已关闭”问题spring-ws 错误?

发布于 2024-09-05 22:37:07 字数 1888 浏览 10 评论 0原文

我有使用 spring-ws 库的工作代码来响应肥皂请求。我将此代码移至另一个项目(我正在合并项目),但现在失败了。我想找出失败的原因。

我得到的症状是这样的:当HTTP请求到达时,spring开始处理调用。然后我得到以下异常:

org.springframework.ws.soap.saaj.SaajSoapEnvelopeException: Could not access envelope: java.io.IOException: Stream closed; nested exception is javax.xml.soap.SOAPException: java.io.IOException: Stream closed
    at org.springframework.ws.soap.saaj.SaajSoapMessage.getEnvelope(SaajSoapMessage.java:109)
        <<more lines that don't matter>>
Caused by: java.io.IOException: Stream closed
    at java.io.PushbackInputStream.ensureOpen(PushbackInputStream.java:57)
    at java.io.PushbackInputStream.read(PushbackInputStream.java:116)
    at org.apache.xerces.impl.XMLEntityManager$RewindableInputStream.read(Unknown Source)
    at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
    at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
    at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
    at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
    ... 30 more

在调试器中检查它,似乎 spring 成功处理了 HTTP 标头,但是当它开始处理 SOAP 消息本身的内容时,它在读取正文的第一个字符时卡住了。对错误消息的一些谷歌搜索表明问题在于明显用于从套接字读取的 PushbackInputStream 被读取了两次,或者可能调用了 close() 然后再读取。

它发生在 spring-ws 内部,而不是我的代码中,并且由于在我将代码移动到新项目之前它运行良好,因此它必须与 spring 的版本或其使用的某些东西(如 axis 或 xerces)有关。但我找不到这些版本的任何差异!以前有人遇到过这个错误吗?或者您对我可以采取的解决此问题的方法有什么建议吗?

I have working code using the spring-ws library to respond to soap requests. I moved this code to a different project (I'm merging projects) and now it is failing. I would like to figure out the reason for the failure.

The symptom I get is this: when the HTTP request arrives, spring begins handling the call. Then I get the following exception:

org.springframework.ws.soap.saaj.SaajSoapEnvelopeException: Could not access envelope: java.io.IOException: Stream closed; nested exception is javax.xml.soap.SOAPException: java.io.IOException: Stream closed
    at org.springframework.ws.soap.saaj.SaajSoapMessage.getEnvelope(SaajSoapMessage.java:109)
        <<more lines that don't matter>>
Caused by: java.io.IOException: Stream closed
    at java.io.PushbackInputStream.ensureOpen(PushbackInputStream.java:57)
    at java.io.PushbackInputStream.read(PushbackInputStream.java:116)
    at org.apache.xerces.impl.XMLEntityManager$RewindableInputStream.read(Unknown Source)
    at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
    at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
    at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
    at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
    ... 30 more

Examining it in a debugger, it appears that spring successfully handles HTTP headers, but then when it begins to process the contents of the SOAP message itself, it chokes when reading the very first character of the body. Some googling for the error message suggests that the problem is that a PushbackInputStream which is apparently used for reading from the socket is read twice or perhaps has close() called and then is read afterward.

It is happening inside of spring-ws, not my code, and since it worked fine before I moved the code to a new project it must have something to do with versions of spring, or something it uses like axis or xerces. But I can't find any differences in versions of these! Has anyone encountered this error before? Or do you have any suggestions of approaches I could take in troubleshooting this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

娇纵 2024-09-12 22:37:07

我的猜测是,在您尝试读取消息正文之前,有东西正在读取流。
这是典型的情况。

如果其他东西正在读取流,它可能会消耗整个流并调用flush()和close(),这会导致您所处的情况。

您是否在两端放置了嗅探器并观察到肥皂消息实际上包含正文?在我看来,这种情况不太可能发生,因为流实际上已关闭并抛出空指针或任何东西。

My guess would be that something is reading the stream before your attempting to read the body of the message.
This is the typical situation.

If something else is reading the stream it could be consuming the entire stream and calling flush() and close() which would cause the situation your in.

Have you put a sniffer on either end and observed that the soap message actually contains a body? This is less likely imo since the stream is actually closed and throwing a null pointer or anything.

自此以后,行同陌路 2024-09-12 22:37:07

最终解决方案:

事实证明,问题根本不在服务器上。相反,我用来发送请求的工具(SoapUI)有问题。非常感谢 Knife-Action-Jesus 建议我调查一下。

Final Resolution:

It turns out that the problem was NOT on the server at all. Instead, there was something wrong with the tool I was using to send the requests (SoapUI). Many thanks to Knife-Action-Jesus for suggesting I look into it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文