通过axis2 Web服务上传350MB的附件时出现OutOfMemory问题

时间:2014-12-01 11:33:26

标签: java web-services tomcat soap mtom

我正在尝试通过SOAP UI(启用MTOM)上传大小为350 MB的附件,并将附件发送到axis2 Web服务。

Axis2 Web服务配置为在服务器端启用MTOM。并且在服务器端也启用了缓存。以下配置在axis2.xml中:

<parameter name="enableMTOM">true</parameter>

<parameter name="cacheAttachments">true</parameter>
<parameter name="attachmentDIR">C:\Temp\TempWS</parameter>
<parameter name="sizeThreshold">8000</parameter>

Tomcat Setting

tomcat中的最大堆大小设置为3000 MB(参见上面的屏幕截图),但仍然是Web服务使我低于异常:

Java heap space
java.lang.OutOfMemoryError: Java heap space
    at java.util.Arrays.copyOfRange(Arrays.java:2694)
    at java.lang.String.<init>(String.java:203)
    at java.lang.StringBuffer.toString(StringBuffer.java:561)
    at org.apache.axiom.util.base64.Base64Utils.encode(Base64Utils.java:81)
    at org.apache.axiom.om.impl.llom.OMTextImpl.getText(OMTextImpl.java:264)
    at org.apache.axiom.om.impl.llom.OMElementImpl.getText(OMElementImpl.java:786)
    at org.apache.axis2.databinding.utils.BeanUtil.deserialize(BeanUtil.java:334)
    at org.apache.axis2.databinding.utils.BeanUtil.deserialize(BeanUtil.java:407)
    at org.apache.axis2.databinding.utils.BeanUtil.processObject(BeanUtil.java:682)
    at org.apache.axis2.databinding.utils.BeanUtil.ProcessElement(BeanUtil.java:630)
    at org.apache.axis2.databinding.utils.BeanUtil.deserialize(BeanUtil.java:562)
    at org.apache.axis2.rpc.receivers.RPCUtil.processRequest(RPCUtil.java:153)
    at org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:188)
    at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:102)
    at org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40)
    at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:114)
    at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:173)
    at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:173)
    at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:144)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
    at com.csdcsystems.amanda.servlet.AmandaAxisServlet.service(AmandaAxisServlet.java:103)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)

我的问题:

  1. 有人能帮我理解我错过的东西吗?在tomcat配置中是否需要有其他设置?
  2. 如何通过axis2网络服务支持上传/下载大型附件?
  3. 注意: 服务配置为将byte []作为服务的输入/输出参数。

1 个答案:

答案 0 :(得分:0)

尝试使用

增加堆空间
C:\tomcat-7.0.57\bin>set JAVA_OPTS=-Xmx1g
C:\tomcat-7.0.57\bin>startup.bat

这将运行带有1GB堆空间的jvm,如果仍然抛出异常尝试2g。

如果您通过eclipse运行tomcat,请转到&#34;运行配置&#34;,选择您的项目,打开&#34; Arguments&#34;选项卡并将-Xmx1g添加到&#34; VM参数&#34;