1 Reply Latest reply on Nov 17, 2008 5:52 AM by Ilya Shaikovsky

    t:inputFileUpload, OutOfMemory Error

    tong tong Newbie

      I use tomahawk t:inputFileUpload component, I set the max file upload size to 100m in web.xml as follow:

      <filter>
       <filter-name>extensionsFilter</filter-name>
       <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
       <init-param>
       <description>Set the size limit for uploaded files.
       Format: 10 - 10 bytes
       10k - 10 KB
       10m - 10 MB
       1g - 1 GB</description>
       <param-name>uploadMaxFileSize</param-name>
       <param-value>100m</param-value>
       </init-param>
       <init-param>
      ..........
      


      but when I just upload a 2M file, OutOfMemory Error occur!! why?
      the full stacetrace is as follow:
      2008-11-17 00:23:33,831 [http-8080-1] ERROR _ErrorPageWriter: An exception occurred
      java.lang.OutOfMemoryError: Java heap space
       at java.util.Arrays.copyOf(Arrays.java:2786)
       at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:94)
       at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:202)
       at sun.nio.cs.StreamEncoder.implWrite(StreamEncoder.java:263)
       at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:106)
       at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:116)
       at java.io.OutputStreamWriter.write(OutputStreamWriter.java:203)
       at java.io.PrintWriter.write(PrintWriter.java:412)
       at java.io.PrintWriter.write(PrintWriter.java:429)
       at org.apache.myfaces.application.jsp.JspViewHandlerImpl$StateMarkerAwareWriter.flushToWriter(JspViewHandlerImpl.java:631)
       at org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspViewHandlerImpl.java:392)
       at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
       at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:196)
       at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:41)
       at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:140)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:155)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:301)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:177)
       at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:267)
       at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:380)
       at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:507)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      2008-11-17 00:23:34,831 [http-8080-1] ERROR BaseXMLFilter: Exception in the filter chain
      javax.servlet.ServletException: Filter execution threw an exception
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:259)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:177)
       at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:267)
       at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:380)
       at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:507)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
       at java.lang.Thread.run(Thread.java:619)
      Caused by: java.lang.OutOfMemoryError: Java heap space
       at java.lang.AbstractStringBuilder.<init>(AbstractStringBuilder.java:45)
       at java.lang.StringBuffer.<init>(StringBuffer.java:103)
       at org.apache.myfaces.renderkit.html.util.DefaultAddResource.parseResponse(DefaultAddResource.java:329)
       at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:311)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       ... 17 more