0 Replies Latest reply on Aug 10, 2008 1:00 PM by Toni Beckman

    s:fileupload OutOfMemory

    Toni Beckman Novice


      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:

      public class PictureArchive implements Serializable
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        long id;
        String fileName;
        @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:

        <%@ include file="common/top.jsp" %>
        <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}"/>
        <%@ include file="common/bottom.jsp" %>

      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.setFileName(fileUploadBean.getName().replaceAll("^.*[\\\\/]", ""));
            return "files";
          return "file";