【问题标题】:javax.xml.ws.WebServiceException: java.io.IOException: Error writing to server Tomcat 8javax.xml.ws.WebServiceException:java.io.IOException:写入服务器 Tomcat 8 时出错
【发布时间】:2015-12-02 21:33:53
【问题描述】:

我们最近将在 JRE 1.7.0_17/Tomcat7.0.39 上运行的 JAX-WS Web 服务的技术堆栈更新为 JRE 1.8.0_66/Tomcat 8.0.28。 Web 应用程序在 Windows Server 2012 上运行。Web 服务使用用于 JAX-WS 的 Metro 实现。客户端使用 JRE 7 和 JRE 中内置的 JAX-WS 客户端 API 在各种 Windows 版本上运行。网络服务用于将文件从客户端机器上传到网络服务,网络服务将它们保存在文档管理系统中。该实现在 Java 7/Tomcat 7 下运行得非常完美,但我们遇到了在 Java 8/Tomcat 8 服务器端运行较大负载(2MB 或更大)的问题。来自客户端的堆栈跟踪是:

12/02/2015 14:12:38.699 [AWT-EventQueue-0] ERROR  DocumentImporterMainWindow$SwingAction.importDocument: Unexpected Problem trying to call the CustomerOrderDMService
javax.xml.ws.WebServiceException: java.io.IOException: Error writing to server
    at com.sun.xml.internal.ws.transport.http.client.HttpClientTransport.readResponseCodeAndMessage(Unknown Source)
    at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.createResponsePacket(Unknown Source)
    at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.process(Unknown Source)
    at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.processRequest(Unknown Source)
    at com.sun.xml.internal.ws.transport.DeferredTransportPipe.processRequest(Unknown Source)
    at com.sun.xml.internal.ws.api.pipe.Fiber.__doRun(Unknown Source)
    at com.sun.xml.internal.ws.api.pipe.Fiber._doRun(Unknown Source)
    at com.sun.xml.internal.ws.api.pipe.Fiber.doRun(Unknown Source)
    at com.sun.xml.internal.ws.api.pipe.Fiber.runSync(Unknown Source)
    at com.sun.xml.internal.ws.client.Stub.process(Unknown Source)
    at com.sun.xml.internal.ws.client.sei.SEIStub.doProcess(Unknown Source)
    at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source)
    at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source)
    at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(Unknown Source)
    at com.sun.proxy.$Proxy30.importDocument(Unknown Source)
    at com.mycompany.documentimporter.DocumentImporterMainWindow$SwingAction.importDocument(DocumentImporterMainWindow.java:681)
    at com.mycompany.documentimporter.DocumentImporterMainWindow$SwingAction.actionPerformed(DocumentImporterMainWindow.java:612)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
    at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$500(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.io.IOException: Error writing to server
    at sun.net.www.protocol.http.HttpURLConnection.writeRequests(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.writeRequests(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    at java.net.HttpURLConnection.getResponseCode(Unknown Source)
    ... 54 more

不幸的是,在任何 tomcat 日志中都没有记录服务器端。我花了几天时间寻找解决问题的方法,但没有成功。我试图通过各种途径来调试问题,例如使用记录 SOAP 请求/响应客户端和服务器端 -Dcom.sun.xml.ws.transport.http.client.HttpTransportPipe.dump=true(客户)和 -Dcom.sun.xml.ws.transport.http.HttpAdapter.dump=true(server) java 系统属性,但是当错误发生时,只记录客户端请求:

---[HTTP request - http://localhost:8080/CustomerOrderDM/services/CustomerOrderDMService]---
Accept: text/xml, multipart/related
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://www.mycompany.com/CustomerOrderDMService/ImportDocument"
User-Agent: JAX-WS RI 2.2.9-b130926.1035 svn-revision#5f6196f2b90e9460065a4c2f4e30e065b245e51e
<?xml version="1.0" ?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><ns3:ImportDocumentRequestDTO xmlns:ns3="http://www.mycompany.com/CustomerOrderDMService/" xmlns:ns2="http://www.mycompany.com/CustomerOrderDMService"><ns2:QuoteNumber>A000049</ns2:QuoteNumber><ns2:SerialNumber>STOCK</ns2:SerialNumber><ns2:DocumentType>Email</ns2:DocumentType><ns2:Description></ns2:Description><ns2:DocumentContents> **some base64 encoded byte[] of the file contents being uploaded**

Message has been truncated
use com.sun.xml.internal.ws.transport.http.HttpAdapter.dumpTreshold property to increase the amount of printed part of the message
--------------------

由于只有客户端请求被记录,我们预计服务器没有完全处理请求并且它陷入某种异常块,但是没有任何记录到服务器日志文件,我们很难解决问题.

我们尝试过使用代理,例如 Eclipse 内置的监控,但我再次只看到来自客户端的请求而没有来自服务器的响应(当客户端发送失败的较大请求时,小请求记录请求/响应在客户端和服务器上)。其他调试建议将不胜感激。

我们也尝试过 Java 和 Tomcat 的不同组合:

  • Tomcat 7/Java 7 = 工作
  • Tomcat 7/Java 8 = 工作
  • Tomcat 8/Java 7 = 不起作用
  • Tomcat 8/Java 8 = 不起作用

这使我们认为问题出在 Tomcat 8 上。要么是 Tomcat 8 中的某些内容发生了变化,我们现在需要设置一些新的超时/有效负载设置,要么是 Tomcat 8 存在与此特定问题相关的错误。

我们已尝试设置一些 Tomcat 连接器设置,例如 maxPostSize="-1"connectionTimeout="-1"disableUploadTimeout="true"connectionUploadTimeout="-1"keepAliveTimeout="-1" 但这些都不起作用,老实说,在不知道服务器端发生了什么的情况下,感觉就像是在黑暗中开枪。

我们尝试将 Metro jars 服务器端更新到最新版本 (jaxws-ri-2.2.10) 并使用 Java 8 运行客户端。不幸的是,这些都不起作用。任何帮助将不胜感激。

【问题讨论】:

    标签: java eclipse web-services tomcat soap


    【解决方案1】:

    原来Tomcat 7.0.55包含Fix:

    CVE-2014-0230:
    Add a new limit, defaulting to 2MB, for the amount of data Tomcat will swallow for an aborted upload. The limit is configurable by maxSwallowSize attribute of an HTTP connector. 
    

    通过在 tomcat 服务器 server.xml 中的 &lt;Connector&gt; 配置上设置 maxSwallowSize="-1" 设置解决了我的问题。

    我要感谢 Tomcat 用户邮件列表中的 Mark Thomas 和 Chris Schultz 的帮助。有关如何加入邮件列表的说明,请单击here。我还要感谢 Vinayak 为我提供 Tomcat 支持。

    【讨论】:

    • 您应该接受自己的答案作为答案。 :)
    • maxSwallowSize 是什么意思?
    【解决方案2】:

    似乎这更多是与 Tomcat 相关的错误。 将问题发布给 Tomcat 团队。

    http://tomcat.apache.org/bugreport.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-11-02
      • 2014-11-20
      • 2017-07-17
      • 1970-01-01
      • 2018-12-05
      • 1970-01-01
      • 2017-02-02
      相关资源
      最近更新 更多