You need to configure the web.xml file to increase the maximum upload file size. I'm not sure where this is documented in Trinidad, perhaps someone else can tell us. I sent Shane the upload file page from the old ADF Developers Guide.
Mark [EMAIL PROTECTED] | www.mizar.com | (360) 945-2643 -----Original Message----- From: Shane Petroff [mailto:[EMAIL PROTECTED] Sent: Monday, December 10, 2007 9:25 AM To: MyFaces Discussion Subject: Re: File download and out of memory Anyone have any guesses even? Is there a better technique? (the code was almost copied/pasted out of the wiki) I had wondered if the buildFile() method was leaving some resources open. Since I don't write a lot of I/O code (and since I wanted to convince myself of my own sanity), it is currently stubbed out to return a handle to a pre-existing file. I've stopped declaring a UTF-8 encoding, although UnicodeEncoder is still invoked. There doesn't appear to be a lot I can change with this. Should I just drop Tomahawk and the ExtensionsFilter altogether and try Trinidad? (is there any documentation on converting over) Shane Shane Petroff wrote: > Hello, > > I'm having a problem with a link used to download a "large" file. I > say large in quotation because by modern standards, the 5MB file I'm > talking about is tiny; I need to be able to handle at least 20MB. The > same code works for small files (<25K), but dies on larger ones. > Hopefully it is a configuration issue. On the jsp, there is a > commandLink bound to the "onDownload" action pasted below. The only > config I can imagine that might come into play is configuring the > extensions filter itself. I've specified UTF-8 encodings by default > since several pages must support extended characters. I'm currently > using MyFaces core 1.1.5, Tomahawk 1.1.6 and Tomcat 5.5.23 > > The stack trace is: > java.lang.OutOfMemoryError: Java heap space > at java.util.Arrays.copyOf(Arrays.java:2882) > at > java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:10 0) > > at > java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:572) > at java.lang.StringBuffer.append(StringBuffer.java:320) > at > org.apache.myfaces.shared_tomahawk.renderkit.html.util.UnicodeEncoder.encode (UnicodeEncoder.java:54) > > (full stack trace below) > > Extension Filter config: > <filter> > <filter-name>MyFacesExtensionsFilter</filter-name> > > <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-clas s> > > <init-param> > <param-name>maxFileSize</param-name> > <param-value>90m</param-value> > </init-param> > <init-param> > <param-name>uploadMaxFileSize</param-name> > <param-value>90m</param-value> > </init-param> > </filter> > > Action code: > public String onDownload() > { > String rtn = Constants.ERROR_OUTCOME; > FileInputStream fis = null; > OutputStream os = null; > try > { > File file = buildFile(); // creates a 5MB file. If I hack > this to return a 25K file, it all works well > > FacesContext fc = FacesContext.getCurrentInstance(); > HttpServletResponse response = (HttpServletResponse) > fc.getExternalContext().getResponse(); > response.setHeader("Content-disposition", "attachment; > filename=" + file.getName()); > response.setContentType("application/xml"); > > fis = new FileInputStream(file); > os = new BufferedOutputStream(response.getOutputStream()); > > int read; > while( (read = fis.read()) != -1 ) > os.write(read); > > os.flush(); > fc.responseComplete(); > rtn = Constants.SUCCESS_OUTCOME; > } > catch ( Exception e ) > { > logException( MessageConstants.LOADING_ERROR_PREFIX + > "XML", e ); > } > finally > { > try > { > os.close(); > fis.close(); > } > catch(Exception ignored) { /* we don't care about NPE's > either */ } > } > > return rtn; > } > > Full Stack Trace: > java.lang.OutOfMemoryError: Java heap space > at java.util.Arrays.copyOf(Arrays.java:2882) > at > java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:10 0) > > at > java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:572) > at java.lang.StringBuffer.append(StringBuffer.java:320) > at > org.apache.myfaces.shared_tomahawk.renderkit.html.util.UnicodeEncoder.encode (UnicodeEncoder.java:54) > > at > org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlResponseWriterImpl.wri te(HtmlResponseWriterImpl.java:567) > > at > org.apache.myfaces.renderkit.html.util.DefaultAddResource.writeResponse(Defa ultAddResource.java:847) > > at > org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter. java:162) > > at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application FilterChain.java:215) > > at > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh ain.java:188) > > at > org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterI nternal(OpenSessionInViewFilter.java:173) > > at > org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestF ilter.java:77) > > at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application FilterChain.java:215) > > at > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh ain.java:188) > > at > ca.mayet.SessionTimeoutRedirectFilter.doFilter(SessionTimeoutRedirectFilter. java:78) > > at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application FilterChain.java:215) > > at > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh ain.java:188) > > at > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja va:210) > > at > org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja va:174) > > at > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127 ) > > at > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117 ) > > at > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java :108) > > at > org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151) > > at > org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870) > > at > org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processC onnection(Http11BaseProtocol.java:665) > > at > org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.jav a:528) > > at > org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWo rkerThread.java:81) > > at > org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.jav a:685) > > at java.lang.Thread.run(Thread.java:619) > -- Shane

