Hi,
I'm using s:fileupload with Seam 1.1.6 to upload files. The problem is that I run into outofmemory, when I try to persist the entity.
The maximum heap size has been set to 2048 mb. The files are around 120 mb big. Any way how I can configure seam and/or hibernate so that I don't run into OutOfMemory errors?
The entity bean:
@Name("pictureArchive") @Entity public class PictureArchive implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) long id; String fileName; @Lob @Basic(fetch = FetchType.LAZY, optional = true) byte data[]; public long getId() { return id; } public void setId(long id) { this.id = id; } public String getFileName() { return fileName; } public void setFileName(String fileName) { this.fileName = fileName; } public byte[] getData() { return data; } public void setData(byte[] data) { this.data = data; } }
The jsp code:
<f:view> <title></title> <%@ include file="common/top.jsp" %> <h1></h1> <h2></h2> <div id="body"> <h:form id="upload" enctype="multipart/form-data"> <s:fileUpload data="#{fileUploadBean.file}" accept="" fileName="#{fileUploadBean.name}"/> <h:commandButton value="Upload" action="#{fileAction.uploadFile}"/> </h:form> </div> <%@ include file="common/bottom.jsp" %> </f:view>
The relevant function in the session bean:
public String uploadFile() { log.info("Call to uploadFile"); if (fileUploadBean.getFile() != null) { log.info("Size: " + fileUploadBean.getFile().length); PictureArchive pictureArchive = new PictureArchive(); pictureArchive.setData(fileUploadBean.getFile()); pictureArchive.setFileName(fileUploadBean.getName().replaceAll("^.*[\\\\/]", "")); entityManager.persist(pictureArchive); return "files"; } return "file"; }