net.sf.ehcache.constructs.web.ResponseHeadersNotModifiableException: Failure when attempting to set Content-Encoding: gzip

Terracotta | Arnauld | 7 years ago
  1. 0

    [GzipFilter] Failure when attempting to set Content-Encoding: gzip - Patch proposal

    Terracotta | 7 years ago | Arnauld
    net.sf.ehcache.constructs.web.ResponseHeadersNotModifiableException: Failure when attempting to set Content-Encoding: gzip
  2. 0

    Does EhCache contain a GZipFilter? It'd be nice to change from using the one we have in AppFuse[1] to one provided by a framework. It doesn't look like any on the following are gzip-only. http://ehcache.sourceforge.net/documentation/j2ee_servlet_caching.html Thanks, Matt [1] http://tinyurl.com/fu5cy Reply Forward Greg Luck to matt, ehcache-list More options Oct 10 Matt Ehcache does provide a standalone gzip filter. See http://ehcache.sourceforge.net/xref/net/sf/ehcache/constructs/web/filter/GzipFilter.html The tests are here: http://ehcache.sourceforge.net/xref-test/net/sf/ehcache/constructs/web/filter/GzipFilterTest.html The CachingFilter has built-in gzipping capability which shares code with the gzip filter, but it sounds like you just want gzipping on its own so I would use this one. Gzipping is the one of the nastiest areas I have ever come across. The bugs are very subtle and difficult to figure out in production. I do not recommend to anyone to roll your own in this area. Better to use a framework where the bugs can get detected and fixed by a larger group of people. - Show quoted text - On 11/10/2006, at 1:13 AM, Matt Raible wrote: > - Show quoted text - > Does EhCache contain a GZipFilter? It'd be nice to change from using > the one we have in AppFuse[1] to one provided by a framework. It > doesn't look like any on the following are gzip-only. > > http://ehcache.sourceforge.net/documentation/j2ee_servlet_caching.html > > Thanks, > > Matt > > [1] http://tinyurl.com/fu5cy > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys -- and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > ehcache-list mailing list > ehcache-list@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/ehcache-list Regards Greg Luck web: http://gregluck.com skype: gregrluck yahoo: gregrluck mobile: +61 408 061 622 Reply Reply to all Forward Invite Greg to Gmail Matt Raible to Greg, ehcache-list More options Oct 10 I gave this filter a whirl and while it works when testing my UI with Canoo WebTest, it doesn't work in Firefox 1.5. I get the following error in my logs: [appfuse] ERROR [http-8080-Processor25] [jsp].invoke(253) | Servlet.service() fo r servlet jsp threw exception net.sf.ehcache.constructs.web.ResponseHeadersNotModifiableException: Failure whe n attempting to set Content-Encoding: gzip at net.sf.ehcache.constructs.web.ResponseUtil.addGzipHeader(ResponseUtil .java:126) at net.sf.ehcache.constructs.web.filter.GzipFilter.doFilter(GzipFilter.j ava:89) at net.sf.ehcache.constructs.web.filter.Filter.doFilter(Filter.java:89) Here's my filters and their mappings from web.xml: <filter> <filter-name>securityFilter</filter-name> <filter-class>org.acegisecurity.util.FilterToBeanProxy</filter-class> <init-param> <param-name>targetClass</param-name> <param-value>org.acegisecurity.util.FilterChainProxy</param-value> </init-param> </filter> <filter> <filter-name>cacheFilter</filter-name> <filter-class>com.opensymphony.oscache.web.filter.CacheFilter</filter-class> </filter> <filter> <filter-name>clickstreamFilter</filter-name> <filter-class>com.opensymphony.clickstream.ClickstreamFilter</filter-class> </filter> <filter> <filter-name>encodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> <init-param> <param-name>forceEncoding</param-name> <param-value>true</param-value> </init-param> </filter> <filter> <filter-name>hibernateFilter</filter-name> <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class> </filter> <filter> <filter-name>rewriteFilter</filter-name> <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class> <init-param> <param-name>logLevel</param-name> <param-value>commons</param-value> </init-param> </filter> <filter> <filter-name>sitemesh</filter-name> <filter-class>com.opensymphony.module.sitemesh.filter.PageFilter</filter-class> </filter> <filter> <filter-name>exportFilter</filter-name> <filter-class>org.displaytag.filter.ResponseOverrideFilter</filter-class> </filter> <filter> <filter-name>compressionFilter</filter-name> <filter-class>net.sf.ehcache.constructs.web.filter.GzipFilter</filter-class> </filter> <filter> <filter-name>localeFilter</filter-name> <filter-class>org.appfuse.webapp.filter.LocaleFilter</filter-class> </filter> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>/j_security_check</url-pattern> </filter-mapping> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>/dwr/*</url-pattern> </filter-mapping> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>*.html</url-pattern> </filter-mapping> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>*.jsp</url-pattern> </filter-mapping> <filter-mapping> <filter-name>securityFilter</filter-name> <url-pattern>/j_security_check</url-pattern> </filter-mapping> <filter-mapping> <filter-name>securityFilter</filter-name> <url-pattern>/dwr/*</url-pattern> </filter-mapping> <filter-mapping> <filter-name>securityFilter</filter-name> <url-pattern>*.html</url-pattern> </filter-mapping> <filter-mapping> <filter-name>securityFilter</filter-name> <url-pattern>*.jsp</url-pattern> </filter-mapping> <!-- Commented out for 2 reasons: 1) it's a pain when developing JSPs, and 2) it causes the Signup webtest to fail --> <!--filter-mapping> <filter-name>cacheFilter</filter-name> <url-pattern>*.jsp</url-pattern> </filter-mapping--> <filter-mapping> <filter-name>hibernateFilter</filter-name> <url-pattern>*.html</url-pattern> </filter-mapping> <filter-mapping> <filter-name>clickstreamFilter</filter-name> <url-pattern>*.html</url-pattern> </filter-mapping> <filter-mapping> <filter-name>localeFilter</filter-name> <url-pattern>*.html</url-pattern> </filter-mapping> <filter-mapping> <filter-name>localeFilter</filter-name> <url-pattern>*.jsp</url-pattern> </filter-mapping> <filter-mapping> <filter-name>exportFilter</filter-name> <url-pattern>*.html</url-pattern> </filter-mapping> <filter-mapping> <filter-name>compressionFilter</filter-name> <url-pattern>*.css</url-pattern> </filter-mapping> <filter-mapping> <filter-name>compressionFilter</filter-name> <url-pattern>*.jsp</url-pattern> </filter-mapping> <filter-mapping> <filter-name>compressionFilter</filter-name> <url-pattern>*.js</url-pattern> </filter-mapping> <filter-mapping> <filter-name>compressionFilter</filter-name> <url-pattern>*.html</url-pattern> </filter-mapping> <filter-mapping> <filter-name>rewriteFilter</filter-name> <url-pattern>/*</url-pattern> <!--dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher--> </filter-mapping> <filter-mapping> <filter-name>sitemesh</filter-name> <url-pattern>/*</url-pattern> <!--dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher--> </filter-mapping> Thanks, Matt - Show quoted text - On 10/10/06, Greg Luck <gluck@gregluck.com> wrote: > > Matt > > Ehcache does provide a standalone gzip filter. See > http://ehcache.sourceforge.net/xref/net/sf/ehcache/constructs/web/filter/GzipFilter.html > > The tests are here: > http://ehcache.sourceforge.net/xref-test/net/sf/ehcache/constructs/web/filter/GzipFilterTest.html > > The CachingFilter has built-in gzipping capability which shares code with > the gzip filter, but it sounds like > you just want gzipping on its own so I would use this one. > > Gzipping is the one of the nastiest areas I have ever come across. The bugs > are very subtle and difficult to > figure out in production. I do not recommend to anyone to roll your own in > this area. Better to use a framework > where the bugs can get detected and fixed by a larger group of people. > > > > On 11/10/2006, at 1:13 AM, Matt Raible wrote: > > Does EhCache contain a GZipFilter? It'd be nice to change from using > the one we have in AppFuse[1] to one provided by a framework. It > doesn't look like any on the following are gzip-only. > > http://ehcache.sourceforge.net/documentation/j2ee_servlet_caching.html > > Thanks, > > Matt > > [1] http://tinyurl.com/fu5cy > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys -- and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > ehcache-list mailing list > ehcache-list@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/ehcache-list > > > Regards > > > > > Greg Luck > > web: http://gregluck.com > skype: gregrluck > yahoo: gregrluckmobile: +61 408 061 622 > > > > Reply Reply to all Forward Greg Luck to matt, ehcache-list More options Oct 11 Matt The filter only gzips if accept encoding is advertised in the request. I suspect your canoo test is not doing that. Firefox will be. The error you are seeing is because we cannot modify the response header. According to the Servlet 2.4 spec this can happen when: The {@link javax.servlet.ServletResponse#isCommitted()}. The {@link javax.servlet.RequestDispatcher#include(javax.servlet.ServletRequest, javax.servlet.ServletResponse)} method was used to call the resource. The filter throws an exception here rather than gzipping the content without setting the header, which of course would cause the web page to be delivered gzipped without the header set. From there whether the page works depends on the browser. Firefox copes with, IE 5.5 and 6 do not. So the question becomes: which of the two scenarios above is happening and what filter is doing it? You can debug this by removing upstream filters from the filter chain one at a time.

    AppFuse JIRA | 1 decade ago | Matt Raible
    net.sf.ehcache.constructs.web.ResponseHeadersNotModifiableException: Failure whe n attempting to set Content-Encoding: gzip
  3. 0

    Does EhCache contain a GZipFilter? It'd be nice to change from using the one we have in AppFuse[1] to one provided by a framework. It doesn't look like any on the following are gzip-only. http://ehcache.sourceforge.net/documentation/j2ee_servlet_caching.html Thanks, Matt [1] http://tinyurl.com/fu5cy Reply Forward Greg Luck to matt, ehcache-list More options Oct 10 Matt Ehcache does provide a standalone gzip filter. See http://ehcache.sourceforge.net/xref/net/sf/ehcache/constructs/web/filter/GzipFilter.html The tests are here: http://ehcache.sourceforge.net/xref-test/net/sf/ehcache/constructs/web/filter/GzipFilterTest.html The CachingFilter has built-in gzipping capability which shares code with the gzip filter, but it sounds like you just want gzipping on its own so I would use this one. Gzipping is the one of the nastiest areas I have ever come across. The bugs are very subtle and difficult to figure out in production. I do not recommend to anyone to roll your own in this area. Better to use a framework where the bugs can get detected and fixed by a larger group of people. - Show quoted text - On 11/10/2006, at 1:13 AM, Matt Raible wrote: > - Show quoted text - > Does EhCache contain a GZipFilter? It'd be nice to change from using > the one we have in AppFuse[1] to one provided by a framework. It > doesn't look like any on the following are gzip-only. > > http://ehcache.sourceforge.net/documentation/j2ee_servlet_caching.html > > Thanks, > > Matt > > [1] http://tinyurl.com/fu5cy > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys -- and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > ehcache-list mailing list > ehcache-list@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/ehcache-list Regards Greg Luck web: http://gregluck.com skype: gregrluck yahoo: gregrluck mobile: +61 408 061 622 Reply Reply to all Forward Invite Greg to Gmail Matt Raible to Greg, ehcache-list More options Oct 10 I gave this filter a whirl and while it works when testing my UI with Canoo WebTest, it doesn't work in Firefox 1.5. I get the following error in my logs: [appfuse] ERROR [http-8080-Processor25] [jsp].invoke(253) | Servlet.service() fo r servlet jsp threw exception net.sf.ehcache.constructs.web.ResponseHeadersNotModifiableException: Failure whe n attempting to set Content-Encoding: gzip at net.sf.ehcache.constructs.web.ResponseUtil.addGzipHeader(ResponseUtil .java:126) at net.sf.ehcache.constructs.web.filter.GzipFilter.doFilter(GzipFilter.j ava:89) at net.sf.ehcache.constructs.web.filter.Filter.doFilter(Filter.java:89) Here's my filters and their mappings from web.xml: <filter> <filter-name>securityFilter</filter-name> <filter-class>org.acegisecurity.util.FilterToBeanProxy</filter-class> <init-param> <param-name>targetClass</param-name> <param-value>org.acegisecurity.util.FilterChainProxy</param-value> </init-param> </filter> <filter> <filter-name>cacheFilter</filter-name> <filter-class>com.opensymphony.oscache.web.filter.CacheFilter</filter-class> </filter> <filter> <filter-name>clickstreamFilter</filter-name> <filter-class>com.opensymphony.clickstream.ClickstreamFilter</filter-class> </filter> <filter> <filter-name>encodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> <init-param> <param-name>forceEncoding</param-name> <param-value>true</param-value> </init-param> </filter> <filter> <filter-name>hibernateFilter</filter-name> <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class> </filter> <filter> <filter-name>rewriteFilter</filter-name> <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class> <init-param> <param-name>logLevel</param-name> <param-value>commons</param-value> </init-param> </filter> <filter> <filter-name>sitemesh</filter-name> <filter-class>com.opensymphony.module.sitemesh.filter.PageFilter</filter-class> </filter> <filter> <filter-name>exportFilter</filter-name> <filter-class>org.displaytag.filter.ResponseOverrideFilter</filter-class> </filter> <filter> <filter-name>compressionFilter</filter-name> <filter-class>net.sf.ehcache.constructs.web.filter.GzipFilter</filter-class> </filter> <filter> <filter-name>localeFilter</filter-name> <filter-class>org.appfuse.webapp.filter.LocaleFilter</filter-class> </filter> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>/j_security_check</url-pattern> </filter-mapping> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>/dwr/*</url-pattern> </filter-mapping> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>*.html</url-pattern> </filter-mapping> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>*.jsp</url-pattern> </filter-mapping> <filter-mapping> <filter-name>securityFilter</filter-name> <url-pattern>/j_security_check</url-pattern> </filter-mapping> <filter-mapping> <filter-name>securityFilter</filter-name> <url-pattern>/dwr/*</url-pattern> </filter-mapping> <filter-mapping> <filter-name>securityFilter</filter-name> <url-pattern>*.html</url-pattern> </filter-mapping> <filter-mapping> <filter-name>securityFilter</filter-name> <url-pattern>*.jsp</url-pattern> </filter-mapping> <!-- Commented out for 2 reasons: 1) it's a pain when developing JSPs, and 2) it causes the Signup webtest to fail --> <!--filter-mapping> <filter-name>cacheFilter</filter-name> <url-pattern>*.jsp</url-pattern> </filter-mapping--> <filter-mapping> <filter-name>hibernateFilter</filter-name> <url-pattern>*.html</url-pattern> </filter-mapping> <filter-mapping> <filter-name>clickstreamFilter</filter-name> <url-pattern>*.html</url-pattern> </filter-mapping> <filter-mapping> <filter-name>localeFilter</filter-name> <url-pattern>*.html</url-pattern> </filter-mapping> <filter-mapping> <filter-name>localeFilter</filter-name> <url-pattern>*.jsp</url-pattern> </filter-mapping> <filter-mapping> <filter-name>exportFilter</filter-name> <url-pattern>*.html</url-pattern> </filter-mapping> <filter-mapping> <filter-name>compressionFilter</filter-name> <url-pattern>*.css</url-pattern> </filter-mapping> <filter-mapping> <filter-name>compressionFilter</filter-name> <url-pattern>*.jsp</url-pattern> </filter-mapping> <filter-mapping> <filter-name>compressionFilter</filter-name> <url-pattern>*.js</url-pattern> </filter-mapping> <filter-mapping> <filter-name>compressionFilter</filter-name> <url-pattern>*.html</url-pattern> </filter-mapping> <filter-mapping> <filter-name>rewriteFilter</filter-name> <url-pattern>/*</url-pattern> <!--dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher--> </filter-mapping> <filter-mapping> <filter-name>sitemesh</filter-name> <url-pattern>/*</url-pattern> <!--dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher--> </filter-mapping> Thanks, Matt - Show quoted text - On 10/10/06, Greg Luck <gluck@gregluck.com> wrote: > > Matt > > Ehcache does provide a standalone gzip filter. See > http://ehcache.sourceforge.net/xref/net/sf/ehcache/constructs/web/filter/GzipFilter.html > > The tests are here: > http://ehcache.sourceforge.net/xref-test/net/sf/ehcache/constructs/web/filter/GzipFilterTest.html > > The CachingFilter has built-in gzipping capability which shares code with > the gzip filter, but it sounds like > you just want gzipping on its own so I would use this one. > > Gzipping is the one of the nastiest areas I have ever come across. The bugs > are very subtle and difficult to > figure out in production. I do not recommend to anyone to roll your own in > this area. Better to use a framework > where the bugs can get detected and fixed by a larger group of people. > > > > On 11/10/2006, at 1:13 AM, Matt Raible wrote: > > Does EhCache contain a GZipFilter? It'd be nice to change from using > the one we have in AppFuse[1] to one provided by a framework. It > doesn't look like any on the following are gzip-only. > > http://ehcache.sourceforge.net/documentation/j2ee_servlet_caching.html > > Thanks, > > Matt > > [1] http://tinyurl.com/fu5cy > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys -- and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > ehcache-list mailing list > ehcache-list@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/ehcache-list > > > Regards > > > > > Greg Luck > > web: http://gregluck.com > skype: gregrluck > yahoo: gregrluckmobile: +61 408 061 622 > > > > Reply Reply to all Forward Greg Luck to matt, ehcache-list More options Oct 11 Matt The filter only gzips if accept encoding is advertised in the request. I suspect your canoo test is not doing that. Firefox will be. The error you are seeing is because we cannot modify the response header. According to the Servlet 2.4 spec this can happen when: The {@link javax.servlet.ServletResponse#isCommitted()}. The {@link javax.servlet.RequestDispatcher#include(javax.servlet.ServletRequest, javax.servlet.ServletResponse)} method was used to call the resource. The filter throws an exception here rather than gzipping the content without setting the header, which of course would cause the web page to be delivered gzipped without the header set. From there whether the page works depends on the browser. Firefox copes with, IE 5.5 and 6 do not. So the question becomes: which of the two scenarios above is happening and what filter is doing it? You can debug this by removing upstream filters from the filter chain one at a time.

    AppFuse JIRA | 1 decade ago | Matt Raible
    net.sf.ehcache.constructs.web.ResponseHeadersNotModifiableException: Failure whe n attempting to set Content-Encoding: gzip
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. net.sf.ehcache.constructs.web.ResponseHeadersNotModifiableException

      Failure when attempting to set Content-Encoding: gzip

      at net.sf.ehcache.constructs.web.ResponseUtil.addGzipHeader()
    2. Ehcache
      ResponseUtil.addGzipHeader
      1. net.sf.ehcache.constructs.web.ResponseUtil.addGzipHeader(ResponseUtil.java:128)
      1 frame
    3. Ehcache Web Filters
      Filter.doFilter
      1. net.sf.ehcache.constructs.web.filter.GzipFilter.doFilter(GzipFilter.java:116)
      2. net.sf.ehcache.constructs.web.filter.Filter.doFilter(Filter.java:86)
      2 frames
    4. Atmosphere weblogic
      FilterChainImpl.doFilter
      1. weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
      1 frame