[users@httpd] "java.lang.OutOfMemoryException : Java heap space" for download due to ExtensionsFilter
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Hi All,
I need help ...
I'm using the Tomahawk library in our project. In web.xml I have an entry as follows ...,
--------------------
<filter>
<filter-name>MyFacesExtensionsFilter</filter-name>
<filter-class>org.apache.myfaces.component.html.util.ExtensionsFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>MyFacesExtensionsFilter</filter-name>
<!-- servlet-name must match the name of your javax.faces.webapp.FacesServlet entry -->
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
<!-- extension mapping for serving page-independent resources (_javascript_, stylesheets, images, etc.) -->
<filter-mapping>
<filter-name>MyFacesExtensionsFilter</filter-name>
<url-pattern>/faces/myFacesExtensionResource/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>MyFacesExtensionsFilter</filter-name>
<url-pattern>*.jsf</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>MyFacesExtensionsFilter</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>
-------------------------
In the project I have download code as follows :
private void copyFileToResponse(HttpServletResponse response, FileInputStream fileIn) throws IOException {
int BUFF_SIZE=4096;
byte[] buffer = new byte[BUFF_SIZE];
ServletOutputStream responseOutStream = response.getOutputStream();
BufferedInputStream buf = new BufferedInputStream(fileIn);
int n = 0;
int count = 0;
while((n = buf.read
(buffer)) != -1) {
// responseOutStream.write(buffer);
LOGGER.info("while loop : before write to Buffer and count => " + count);
responseOutStream.write
(buffer,0,n);
count += n;
LOGGER.info("while loop : copyFileToResponse flush");
responseOutStream.flush();
LOGGER.info("while loop : copyFileToResponse flushBuffer");
LOGGER.info("while loop : after buffer read");
}
LOGGER.info("after while loop : before flushbuffer");
buf.close();
LOGGER.info("after while loop : before flushbuffer");
response.flushBuffer();
responseOutStream.close();
LOGGER.info("after while loop : after flushbuffer");
}
My problem is as follows,
If I have the mentioned entries in the web xml and I'm trying to downlaod > 100 MB file,
the above code, throws
"java.lang.OutOfMemoryException : Java heap space"
org.apache.catalina.connector.CoyoteOutputStream.
But it works fine if I remove the entries from the
web.xml file.
I have debuuged and found that if I keep above "MyFacesExtensionsFilter" related entries in web.xml, the response is instantiated from org.apache.myfaces.component.html.util.ExtensionsResponseWrapper
, in which case flush() doesn't work and causes the "java.lang.OutOfMemoryException : Java heap space" error.
If I remove the MyFacesExtensionsFilter related entries, the response gets instantiated by
"org.apache.catalina.connector.CoyoteOutputStream", in which case flush works fine.
Can anyone tell me how to avoid this situation by still maintaing the "MyFacesExtensionsFilter" related entries in the
web.xml.
Regards,
Datta
[Index of Archives]
[Open SSH Users]
[Linux ACPI]
[Linux Kernel]
[Linux Laptop]
[Kernel Newbies]
[Security]
[Netfilter]
[Bugtraq]
[Squid]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Samba]
[Video 4 Linux]
[Device Mapper]