You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Ognjen Blagojevic <og...@gmail.com> on 2011/12/20 13:14:52 UTC

MTOM not caching attachments with POJO web service (OutOfMemoryError as a result)

Hi,

I developed sample POJO web service (code-first, WSDL is generated by 
Axis2), and enabled MTOM and caching in services.xml descriptor. 
However, I get OutOfMemoryError on the server side. Logging revealed 
that parameter "cacheAttachments" stated in service.xml descriptor is 
not taken into account. Is this a known problem with POJO web services? 
Should I create an issue for this problem?

I'm using Axis2 1.6.1, Tomcat 7.0.22, Oracle/Sun Java 1.6.0_24, Tomcat 
starts with -Xmx512m, and test file size for sending is about 500MB.

Detailed infromation below.

Regards,
Ognjen






==== services.xml:
<service name="(snip)" scope="soapsession">

   <Description>(snip)</Description>

   <parameter name="ServiceClass" locked="xsd:false">
     (snip).ws.WebService
   </parameter>

   <parameter name="enableMTOM">true</parameter>
   <parameter name="cacheAttachments">true</parameter>
   <parameter name="attachmentDIR">d:\__AXIS2_MTOM_TEMP2</parameter>
   <parameter name="sizeThreshold">4000</parameter>


   <messageReceivers>
     <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
       class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
     <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
       class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver" />
   </messageReceivers>

</service>
----


==== axis2.log (excerpt):
2011-12-20 11:58:26,945 [http-bio-8443-exec-1] DEBUG 
org.apache.axiom.attachments.Attachments  - Attachments contentLength=0, 
contentTypeString=multipart/related; 
boundary="MIMEBoundary_41430b93de3ec2903a95c2a03665bd782ef39762bfe1cc1d"; type="application/xop+xml"; 
start="<0....@apache.org>"; 
start-info="application/soap+xml"; action="urn:putFile"
2011-12-20 11:58:26,945 [http-bio-8443-exec-1] DEBUG 
org.apache.axiom.attachments.Attachments  - 
boundary=--MIMEBoundary_41430b93de3ec2903a95c2a03665bd782ef39762bfe1cc1d
2011-12-20 11:58:26,945 [http-bio-8443-exec-1] DEBUG 
org.apache.axiom.attachments.Attachments  - getSOAPPartContentID 
rootContentID=<0....@apache.org>
2011-12-20 11:58:26,961 [http-bio-8443-exec-1] DEBUG 
org.apache.axiom.attachments.impl.PartFactory  - Start createPart()
2011-12-20 11:58:26,961 [http-bio-8443-exec-1] DEBUG 
org.apache.axiom.attachments.impl.PartFactory  -   isSOAPPart=true
2011-12-20 11:58:26,961 [http-bio-8443-exec-1] DEBUG 
org.apache.axiom.attachments.impl.PartFactory  -   thresholdSize= 0
2011-12-20 11:58:26,961 [http-bio-8443-exec-1] DEBUG 
org.apache.axiom.attachments.impl.PartFactory  -   attachmentDir=null
2011-12-20 11:58:26,961 [http-bio-8443-exec-1] DEBUG 
org.apache.axiom.attachments.impl.PartFactory  -   messageContentLength 0
2011-12-20 11:58:26,961 [http-bio-8443-exec-1] DEBUG 
org.apache.axiom.attachments.impl.PartFactory  - initHeaders
2011-12-20 11:58:26,961 [http-bio-8443-exec-1] DEBUG 
org.apache.axiom.attachments.impl.PartFactory  - addHeader: 
(Content-Type) value=(application/xop+xml; charset=UTF-8; 
type="application/soap+xml")
2011-12-20 11:58:26,961 [http-bio-8443-exec-1] DEBUG 
org.apache.axiom.attachments.impl.PartFactory  - addHeader: 
(Content-Transfer-Encoding) value=(binary)
2011-12-20 11:58:26,961 [http-bio-8443-exec-1] DEBUG 
org.apache.axiom.attachments.impl.PartFactory  - addHeader: (Content-ID) 
value=(<0....@apache.org>)
2011-12-20 11:58:26,961 [http-bio-8443-exec-1] DEBUG 
org.apache.axiom.attachments.impl.PartFactory  - End initHeaders
----

==== WebService.java (excerpt):
public class WebService {

     public void putFile(DataHandler dataHandler) {
         try {
             File tempFile = new File("d:\\axis2-created-file.bin");
             FileOutputStream fos = new FileOutputStream(tempFile);
             BufferedOutputStream bos = new BufferedOutputStream(fos);
             dataHandler.writeTo(bos);
             bos.flush();
             bos.close();
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
     }
----


==== Stack trace:
2011-12-20 11:59:04,789 [http-bio-8443-exec-1] ERROR 
org.apache.axis2.transport.http.AxisServlet  - Java heap space
java.lang.OutOfMemoryError: Java heap space
	at 
org.apache.axiom.attachments.utils.BAAOutputStream.addBuffer(BAAOutputStream.java:49)
	at 
org.apache.axiom.attachments.utils.BAAOutputStream.readFrom(BAAOutputStream.java:120)
	at 
org.apache.axiom.attachments.impl.BufferUtils.inputStream2OutputStream(BufferUtils.java:76)
	at 
org.apache.axiom.attachments.impl.PartFactory.createPart(PartFactory.java:136)
	at org.apache.axiom.attachments.Attachments.getPart(Attachments.java:728)
	at 
org.apache.axiom.attachments.Attachments.getNextPartDataHandler(Attachments.java:646)
	at 
org.apache.axiom.attachments.Attachments.getDataHandler(Attachments.java:353)
	at 
org.apache.axiom.om.impl.builder.OMAttachmentAccessorMimePartProvider.getDataHandler(OMAttachmentAccessorMimePartProvider.java:45)
	at 
org.apache.axiom.util.stax.xop.XOPDecodingStreamReader$DataHandlerProviderImpl.getDataHandler(XOPDecodingStreamReader.java:81)
	at 
org.apache.axiom.om.impl.llom.OMTextImpl.getDataHandler(OMTextImpl.java:366)
	at 
org.apache.axis2.databinding.typemapping.SimpleTypeMapper.getDataHandler(SimpleTypeMapper.java:185)
	at 
org.apache.axis2.databinding.utils.BeanUtil.processObject(BeanUtil.java:825)
	at 
org.apache.axis2.databinding.utils.BeanUtil.ProcessElement(BeanUtil.java:746)
	at 
org.apache.axis2.databinding.utils.BeanUtil.deserialize(BeanUtil.java:655)
	at org.apache.axis2.rpc.receivers.RPCUtil.processRequest(RPCUtil.java:153)
	at 
org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:206)
	at 
org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver.invokeBusinessLogic(RPCInOnlyMessageReceiver.java:66)
	at 
org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:110)
	at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:181)
	at 
org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:172)
	at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:146)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
	at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
	at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at 
com.example.test.TransactionViewFilter.doFilter(TransactionViewFilter.java:35)
	at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
	at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
	at 
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
	at 
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
	at 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
----


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


[solved] Re: MTOM not caching attachments with POJO web service (OutOfMemoryError as a result)

Posted by Ognjen Blagojevic <og...@gmail.com>.
On 20.12.2011 13:14, Ognjen Blagojevic wrote:
> <parameter name="cacheAttachments">true</parameter>
> <parameter name="attachmentDIR">d:\__AXIS2_MTOM_TEMP2</parameter>
> <parameter name="sizeThreshold">4000</parameter>

Colleage just found what was the problem. Those parameters should go to 
axis2.xml (as described in the docs) and not to services.xml (as I 
wrongly assumed). D'oh!

Thank you, Anja.

-Ognjen

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org