Friday, November 15, 2013

CxfSerlvet OutOfMemoryError

I was working with uploading large files to my Spring application, and I encountered an OutOfMemoryError.

java.lang.OutOfMemoryError: Java heap space
        at java.util.Arrays.copyOf(Arrays.java:2271)
        at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:113)
        at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93)
        at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:140)
        at org.apache.cxf.io.CachedOutputStream.write(CachedOutputStream.java:461)
        at org.apache.cxf.helpers.IOUtils.copy(IOUtils.java:160)
        at org.apache.cxf.helpers.IOUtils.copy(IOUtils.java:104)
        at org.apache.cxf.attachment.AttachmentDataSource.cache(AttachmentDataSource.java:52)
        at org.apache.cxf.attachment.AttachmentDeserializer.cacheStreamedAttachments(AttachmentDeserializer.java:20
8)

If you are using CxfSerlvet, it lets you define the buffer memory (attachment-memory-threshold) and the max upload size (attachment-max-size)



If you are sure you have these set correctly, make sure the attachment-directory exists. If it does, make sure tomcat has permission to write to it.

No comments:

Post a Comment