• Bug
  • Status: Closed
  • 2 Major
  • Resolution: Fixed
  • ehcache-web
  • hhuynh
  • Reporter:
  • October 28, 2009
  • 0
  • Watchers: 3
  • July 15, 2010
  • May 11, 2010

Attachments

Description

I used the EHCache filter but I have an issue of “Response already committed”.

This message appear only with Weblogic, not with Tomcat.

As stayed by the JEE spec, response is committed when headers or content is written.

I look at the code and I am surpised to see that the GenericResponseWrapper intercept the call to set/add headers … but also use super() to propagate the call to the wrapped httpresponseservlet, why ?

I rewrited the GenericResponseWrapper without the super() call, it works. I don’t have anymore my issue.

Comments

Herve Bourzeix 2009-10-28

flushBuffer() was the real issue as soon as I commented super.flushBuffer(); it was working.

Herve Bourzeix 2009-10-28

EHCache 1.6.0 beta Weblogic 10 MP3 Windows Vista 32bit Java(TM) SE Runtime Environment (build 1.6.0_05-b13)

Steve Harris 2009-10-29

Can we take a look at this?

Abhishek Singh 2009-11-10

Not able to reproduce with weblogic-10.0.mp3 and weblogic-10.3.1 on mac and linux. Will try to reproduce on an win xp box.

Abhishek Singh 2009-11-10

Hi Bourzeix,

I had been trying to reproduce this issue but am unable to do so. I wrote up a sample web-app (attached here), which uses the filter net.sf.ehcache.constructs.web.filter.SimpleCachingHeadersPageCachingFilter to cache the generated pages. There is a single page which shows the time at which the page was generated (so that you can verify if its hitting the cache or generating the page again). It even sets the Content Type of the response (which should call add header). But I am not having any problem with weblogic. I am using a different version of weblogic though, which is “WebLogic Server 10.3.1.0” (downloaded from the oracle site). I couldn’t find out a download link/location for the version you specified “Weblogic 10 MP3”. Maybe if you know the download link, you can share it so that I can try with that version. Also I am using the latest versions of ehcache-core and ehcache-web jars (trunk versions). Can you verify you can still see the issue by running the attached sample? You’ll need to hit “http://localhost:/ehcache-web-sample/hello" for the app though its evident from web.xml

Abhishek Singh 2009-11-10

Attached sample war

Abhishek Singh 2009-11-10

Attached sample project source (maven project)

Abhishek Singh 2009-11-16

Resolving as not reproducible until further details are available from user.

Nitin Rana 2009-11-25

Will re-open if there is any update.

Steve Harris 2010-02-15

The user said they had the issue on Weblogic 10.0MP1

WebLogic 10.0MP1

Steve Harris 2010-03-12

Hey hung, can you try and figure this out.

Steve Harris 2010-03-15

@cfedersp and @mlefebvr: which version of ehcache-core and ehcache-web did you use?

Ludovic Orban 2010-03-16

I’ve made some changes today to the GenericResponseWrapper (for EHC-606) which may or may not improve the situation (or worsen it).

I’ve basically done what the original reporter proposed: got rid of the super() calls in setHeader() and addHeader() as the current implementation was buggy in some cases.

Hung Huynh 2010-03-16

Got a hold of WL 10.0MP1 and still can’t reproduce it with the ehcache-web-1.6.2-beta2 and ehcache-web-2.0.0.

Tried out Ludovic changes with ehcache-2.0.1-SNAPSHOT and still couldn’t reproduce the issue.

Hung Huynh 2010-05-07

more on how to reproduce from forum http://forums.terracotta.org/forums/posts/list/2655.page#19868

Hung Huynh 2010-05-11

This function calls super.flushBuffer() which triggers the exception in Weblogic when calling getRequestDispatcher().forward()

// Flushes buffer and commits response to client.
public void flushBuffer() throws IOException {
    flush();
    
    // doing this might leads to response already committed exception
    // when the PageInfo has not yet built but the buffer already flushed
    // Happens in Weblogic when a servlet forward to a JSP page and the forward
    // method trigger a flush before it forwarded to the JSP
    // disableFlushBuffer for that purpose is 'true' by default
    // EHC-447
    if (!disableFlushBuffer) {
        super.flushBuffer();
    }
}

Hung Huynh 2010-05-12

Attached the servicecache.war (got it from forum user) to reproduce/test.

When verifying the issue, please test ehcache-web with all supported appservers to make sure we don’t break anything else.

Thank you.

Hung-

Himadri Singh 2010-07-06

Reproduced w/ ehcache-core-2.0.1 and ehcache-web-2.0.0

net.sf.ehcache.constructs.web.AlreadyCommittedException: Response already committed after doing buildPagebut before writing response from PageInfo.
	at net.sf.ehcache.constructs.web.filter.CachingFilter.doFilter(CachingFilter.java:191)
	at net.sf.ehcache.constructs.web.filter.Filter.doFilter(Filter.java:86)
	at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
	at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3496)
	at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
	at weblogic.security.service.SecurityManager.runAs(Unknown Source)
	at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
	at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
	at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
	at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
	at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)

Works fine w/ ehcache-web-2.0.2 & ehcache-core-2.2.0