OutOfMemory issue coming while uploading an attachment of 350MB via axis2 web services

797 views Asked by At

I am trying to upload the attachment of size 350 MB through SOAP UI(with MTOM enabled) and sending the attachment to axis2 web services.

Axis2 web services is configured to be having MTOM enabled at server end. And caching is also enabled at server side. Following configuration is there in axis2.xml:

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

and

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

Tomcat Setting

Maximum heap size in tomcat is set to be 3000 MB(see screen shot above), but still web services is throwing me below exception:

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)

My Questions:

  1. Can someone help me understand what I am missing? Is there an additional setting that needs to be there in tomcat configuration?
  2. How can I support large attachments to get uploaded/downloaded through axis2 web services?

Note: Service is configured to be having byte[] as services's input/output parameter.

1

There are 1 answers

1
outdev On

Try increasing the heap space with

C:\tomcat-7.0.57\bin>set JAVA_OPTS=-Xmx1g
C:\tomcat-7.0.57\bin>startup.bat

this will run jvm with 1GB of heap space, if still throws exception try 2g.

If you are running tomcat via eclipse, go to "Run Configurations", select your project, open "Arguments" tab and add -Xmx1g to the "VM arguments"