dev@jax-ws.java.net

Re: Large SAAJ attachments and OutOfMemoryError

From: Dmitry Katsubo <dma_k_at_mail.ru>
Date: Thu, 11 Aug 2011 23:29:38 +0200

On 09.08.2011 19:12, Kumar Jayanti wrote:
> When receiving incoming messagges SAAJ can utilize MimePull Parser
> which stores the attachment to file system.
>
> http://weblogs.java.net/blog/kumarjayanti/archive/2009/12/10/summary-proprietary-features-saaj-ri-134
>
> not sure if this will help in this case.
>
> On 09-Aug-2011, at 10:33 PM, Dmitry Katsubo wrote:
>
>> On 08.08.2011 11:36, yann.blazart_at_gmail.com wrote:
>>> Hi ! As I ve no responses, I'm writing to the list.
>>>
>>> I have open a bug http://java.net/jira/browse/JAX_WS-971. As nobody
>>> take it, I've writed a post on the forum, but no more response...
>>>
>>> So, when you modify an outcome message with a Handler, and when you
>>> deal with large attachment,you have a problem, because in the classe
>>> com.sun.xml.ws.message.saaj.SAAJMessage.SAAJAttachment, we have the
>>> following method used by MimeCodec and MTOMCodec :
>>>
>>> public void writeTo(OutputStream os) throws IOException {
>>> os.write(asByteArray());
>>> }
>>>
>>> The document is entirely mounted in memory !
>>>
>>> Is anybody can make a patch to correct this ?

Now I got what you mean. The problem is in SAAJ library, not in JAXB. So
post the bug here: http://java.net/jira/browse/SAAJ

The code of SAAJAttachment.writeTo() should be something like:

  IOUtils.copy(asInputStream(), os);

and iff MimeBodyPart was initialized with SharedInputStream this code do
the job.

-- 
With best regards,
Dmitry