[MAGNOLIA-273] Caching does not work after new thread model. request object no longer valid. Created: 01/Feb/05  Updated: 27/Apr/05  Resolved: 27/Apr/05

Status: Closed
Project: Magnolia
Component/s: core
Affects Version/s: 2.01, 2.1 Final
Fix Version/s: 2.1 Final

Type: Bug Priority: Major
Reporter: Erik Gulliksen Assignee: Sameer Charles
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

(In general)Windows XP and 2000, version 2.0 distribution with updated lib's (equal to 2.01)


Attachments: Text File CacheHandler.java     Text File EntryServlet.java    
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:

 Description   

Waiting for update...

Here is the last mailthread:

Good
I just tried to subsitute the classfiles back to the 2.01 version, and
it is still no caching as fare as i can see.. Will it be able to use the
fixed version,
i hope will be available soon, on the 2.0x version too? Or does it require
to
upgrade to 2.1 when that will be ready?

-Erik

----- Original Message -----
From: "Sameer Charles" <user-list@magnolia.info>
To: <user-list@magnolia.info>
Sent: Friday, January 28, 2005 12:01 PM
Subject: Re: [magnolia-user] Caching have stoped to work..

> Perfect!
>
>> Is this something u find consider implementing in svn Sameer?
>
> sure ll test and update this on the latest TRUNK (2.1) which is different
> than what you guys are working on.
>
>> Is there anyother changes in the 2.01 then java classes? so if i
>> download it i could try just
>> just substitute the lib's, and add my modofied MultipartRequestFilter
>> later?
>
> between 2.0 and 2.01 there are no major changes, its only a bug fix
> release.
> so you can easily replace this class
>
>
> Thanks a lot Kristoffer!
>
> regards
> - Sameer
>
>
>
>
>
> On Jan 28, 2005, at 11:32 AM, Erik Gulliksen wrote:
>
>> Great work Kristoffer!! ..or should i say: Bra jobbet!!
>>
>> Is this something u find consider implementing in svn Sameer?
>>
>> Or should i try to hack it myself?
>>
>> By the way i run on Tomcat and Windows XP on my development computer and
>> i have Tomcat and Windows 2000 on my webserver.
>> I had it working with the initial installation, but somewhere down the
>> line it got messed up :-S
>>
>> I have been building my own lib's from svn using the build_jars.xml.
>> I have only done one change really;
>> - Adding some code in the:
>> info.magnolia.cms.Filter.MultipartRequestFilter to add image scale on
>> upload..
>>
>> It seems to work fine =)
>> I have hardcoded the sizes for now (Think i need to look into it
>> again later)
>> Had not got it right yet, reading from template config :-S
>> It used 1.7 sec to scale a 4.7 MB image to a max 125x125px jpeg
>> thumbnail
>> on my hardware and software configuration.
>>
>> Is there anyother changes in the 2.01 then java classes? so if i
>> download it i could try just
>> just substitute the lib's, and add my modofied MultipartRequestFilter
>> later?
>>
>> Regards
>> -Erik
>>
>>
>> ----- Original Message ----- From: "Kristoffer Moe"
>> <user-list@magnolia.info>
>> To: <user-list@magnolia.info>
>> Sent: Friday, January 28, 2005 10:44 AM
>> Subject: Re: [magnolia-user] Caching have stoped to work..
>>
>>
>>> Hi, Sameer
>>> Actually, the cache doesn't work, it seems to be inherently broken.
>>> Here
>>> is why:
>>>
>>> The caching mechanism is inherently broken due to a race condition in
>>> CahceProcess. This thread object is given a reference to the
>>> HttpServletRequest object, for it to make a separate request for the
>>> resource to persist at its own pace. The problen is that after the
>>> doGet(...) has finished, the original thread seems to recycle the
>>> request
>>> object by resetting all its content, thereby making the cache try to
>>> persist the URI "/". The cache simply doesn't work in my environment.
>>> Which, BTW, is Magnolia public running i JBoss 3.2.5 on W2K,
>>> repositories
>>> outside in file tree. Author runs on separate Tomcat 5.
>>>
>>>
>>> To remedy this sutiation, i created an inner class of the EntryServlet,
>>> which basically is a dummy implementation of the HttpServletRequest
>>> interface, only providing the information neccesary for caching. Here
>>> is
>>> an excerpt of the class:
>>>
>>> private class CacheRequest implements HttpServletRequest {
>>> Map attributes = new HashMap();
>>> Map headers = new HashMap();
>>> String URI;
>>>
>>> public CacheRequest(HttpServletRequest originalRequest)
>>>

{ >>> // remember URI >>> URI = originalRequest.getRequestURI(); >>> >>> // copy neccessary attributes >>> attributes.put(Aggregator.EXTENSION, >>> originalRequest >>> .getAttribute(Aggregator.EXTENSION)); >>> attributes.put(Aggregator.ACTPAGE, >>> originalRequest >>> >>> .getAttribute(Aggregator.ACTPAGE)); >>> >>> // copy headers >>> String authHeader = >>> originalRequest.getHeader("Authorization"); if >>> (null != authHeader) >>> headers.put("Authorization", >>> authHeader); >>> }

>>>
>>> public String getRequestURI()

{ >>> return URI; >>> }

>>>
>>> public String getHeader(String arg0)

{ >>> return (String) headers.get(arg0); >>> }

>>>
>>> public Object getAttribute(String arg0)

{ >>> return attributes.get(arg0); >>> }

>>>
>>> // implement all other methods as dummy, throwing
>>> UnsupportedOperationException
>>>
>>>
>>> }
>>>
>>>
>>> The class is used to wrap the actual request thus:
>>>
>>> //in EntryServlet.doGet(...):
>>> ...
>>> CacheProcess cache = new CacheProcess(new CacheRequest(req));
>>> cache.start();
>>> ...
>>>
>>>
>>> I've patched my local copy of Magnolia, but I leave it up to you for
>>> now
>>> to include any changes to the source repository.
>>>
>>>
>>>
>>>
>>>> Hi Erik
>>>>
>>>> this error is not related to caching, this is simply a dump from GUI
>>> saying user does not have its own acl.
>>>> for me caching works fine, the only change from 2.0 to 2.01 is that it
>>> runs in a separate thread.. I have to test it on different platforms.
>>> which platform you are running on?
>>>>
>>>> for the time being you can rollback these classes to the previous
>>>> version
>>>> 1. servlets/EntryServlet
>>>> 2. core/CacheHandler
>>>>
>>>>
>>>>
>>>> regards
>>>> - Sameer
>>>>
>>>>
>>>>
>>>> On Jan 27, 2005, at 1:12 PM, Erik Gulliksen wrote:
>>>>
>>>>> Hi all
>>>>> I had caching working when i first installed it, but i have built it
>>> from svn before and now i cant get it running no more..
>>>>> Here is a cut of my info log;
>>>>> info.magnolia.cms.security.SessionAccessControl 27.01.2005
>>>>> 3:02:04 –
>>>>> ERROR – /erikgu/acl_website
>>>>> javax.jcr.PathNotFoundException: /erikgu/acl_website
>>>>> at
>>>>> org.apache.slide.jcr.core.HierarchyManagerImpl.resolvePath(Hierarchy
>>>>> Man
>>> agerImpl.java:237)
>>>>> at
>>>>> org.apache.slide.jcr.core.ItemManager.getItem(ItemManager.java:198)
>>> at org.apache.slide.jcr.core.NodeImpl.getNode(NodeImpl.java:1421) at
>>> info.magnolia.cms.core.Content.init(Content.java:194)
>>>>> at info.magnolia.cms.core.Content.<init>(Content.java:92)
>>>>> at info.magnolia.cms.core.ContentNode.<init>(ContentNode.java:73) at
>>> info.magnolia.cms.core.Content.getContentNode(Content.java:209) at
>>>>> info.magnolia.cms.security.SessionAccessControl.updateACL(SessionAcc
>>>>> ess
>>> Control.java:235)
>>>>> at
>>>>> info.magnolia.cms.security.SessionAccessControl.createRepositorySess
>>>>> ion
>>> (SessionAccessControl.java:179)
>>>>> at
>>>>> info.magnolia.cms.security.SessionAccessControl.getRepositorySession
>>>>> (Se
>>> ssionAccessControl.java:144)
>>>>> at
>>>>> info.magnolia.cms.security.SessionAccessControl.getSession(SessionAc
>>>>> ces
>>> sControl.java:97)
>>>>> at
>>>>> info.magnolia.cms.security.SessionAccessControl.createHierarchyManag
>>>>> er(
>>> SessionAccessControl.java:189)
>>>>> at
>>>>> info.magnolia.cms.security.SessionAccessControl.getHierarchyManager(
>>>>> Ses
>>> sionAccessControl.java:130)
>>>>> at
>>>>> info.magnolia.cms.security.SessionAccessControl.getHierarchyManager(
>>>>> Ses
>>> sionAccessControl.java:111)
>>>>> at info.magnolia.cms.Aggregator.collect(Aggregator.java:152)
>>>>> at info.magnolia.cms.servlets.EntryServlet.doGet(EntryServlet.java:
>>>>> 118)
>>> at javax.servlet.http.HttpServlet.service(HttpServlet.java:697) at
>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:810) at
>>>>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(App
>>>>> lic
>>> ationFilterChain.java:237)
>>>>> at
>>>>> org.apache.catalina.core.ApplicationFilterChain.doFilter(Application
>>>>> Fil
>>> terChain.java:157)
>>>>> at
>>>>> org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDis
>>>>> pat
>>> cher.java:703)
>>>>> at
>>>>> org.apache.catalina.core.ApplicationDispatcher.processRequest(Applic
>>>>> ati
>>> onDispatcher.java:463)
>>>>> at
>>>>> org.apache.catalina.core.ApplicationDispatcher.doForward(Application
>>>>> Dis
>>> patcher.java:398)
>>>>> at
>>>>> org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDi
>>>>> spa
>>> tcher.java:312)
>>>>> at
>>>>> info.magnolia.cms.servlets.EntryServlet.redirect(EntryServlet.java:
>>>>> 213)
>>>>> at info.magnolia.cms.servlets.EntryServlet.doGet(EntryServlet.java:
>>>>> 108)
>>> at javax.servlet.http.HttpServlet.service(HttpServlet.java:697) at
>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:810) at
>>>>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(App
>>>>> lic
>>> ationFilterChain.java:237)
>>>>> at
>>>>> org.apache.catalina.core.ApplicationFilterChain.doFilter(Application
>>>>> Fil
>>> terChain.java:157)
>>>>> at
>>>>> info.magnolia.cms.Filter.MultipartRequestFilter.doFilter(MultipartRe
>>>>> que
>>> stFilter.java:76)
>>>>> at
>>>>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(App
>>>>> lic
>>> ationFilterChain.java:186)
>>>>> at
>>>>> org.apache.catalina.core.ApplicationFilterChain.doFilter(Application
>>>>> Fil
>>> terChain.java:157)
>>>>> at
>>>>> info.magnolia.cms.Filter.ContentTypeFilter.doFilter(ContentTypeFilte
>>>>> r.j
>>> ava:52)
>>>>> at
>>>>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(App
>>>>> lic
>>> ationFilterChain.java:186)
>>>>> at
>>>>> org.apache.catalina.core.ApplicationFilterChain.doFilter(Application
>>>>> Fil
>>> terChain.java:157)
>>>>> at
>>>>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapper
>>>>> Val
>>> ve.java:214)
>>>>> at
>>>>> org.apache.catalina.core.StandardValveContext.invokeNext(StandardVal
>>>>> veC
>>> ontext.java:104)
>>>>> at
>>>>> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.ja
>>>>> va:
>>> 520)
>>>>> at
>>>>> org.apache.catalina.core.StandardContextValve.invokeInternal(Standar
>>>>> dCo
>>> ntextValve.java:198)
>>>>> at
>>>>> org.apache.catalina.core.StandardContextValve.invoke(StandardContext
>>>>> Val
>>> ve.java:152)
>>>>> at
>>>>> org.apache.catalina.core.StandardValveContext.invokeNext(StandardVal
>>>>> veC
>>> ontext.java:104)
>>>>> at
>>>>> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.ja
>>>>> va:
>>> 520)
>>>>> at
>>>>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.
>>>>> jav
>>> a:137)
>>>>> at
>>>>> org.apache.catalina.core.StandardValveContext.invokeNext(StandardVal
>>>>> veC
>>> ontext.java:104)
>>>>> at
>>>>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.
>>>>> jav
>>> a:117)
>>>>> at
>>>>> org.apache.catalina.core.StandardValveContext.invokeNext(StandardVal
>>>>> veC
>>> ontext.java:102)
>>>>> at
>>>>> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.ja
>>>>> va:
>>> 520)
>>>>> at
>>>>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVa
>>>>> lve
>>> .java:109)
>>>>> at
>>>>> org.apache.catalina.core.StandardValveContext.invokeNext(StandardVal
>>>>> veC
>>> ontext.java:104)
>>>>> at
>>>>> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.ja
>>>>> va:
>>> 520)
>>>>> at
>>>>> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java: 929)
>>>>> at
>>>>> org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:
>>>>> 160)
>>>>> at
>>>>> org.apache.coyote.http11.Http11Processor.process(Http11Processor.jav
>>>>> a:
>>> 793)
>>>>> at
>>>>> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proc
>>>>> ess
>>> Connection(Http11Protocol.java:702)
>>>>> at
>>>>> org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.jav
>>>>> a:
>>> 571)
>>>>> at
>>>>> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(Thread
>>>>> Poo
>>> l.java:644)
>>>>> at java.lang.Thread.run(Thread.java:534)
>>>>> info.magnolia.cms.Dispatcher 27.01.2005 13:02:04 – INFO –
>>>>> Dispatching request for - http://localhost:8082/
>>>>> info.magnolia.cms.Dispatcher 27.01.2005 13:02:04 – INFO – Forward
>>>>> to
>>> - /templates/jsp/toyota/news/inside.jsp
>>>>> info.magnolia.cms.util.Resource 27.01.2005 13:02:05 – INFO –
>>>>> Deprecated : use
>>>>> SessionAccessControl.getHierarchyManager(HttpServletRequest,String)
>>> instead
>>>>> Anyone have a summary of what i have to check to be sure it is all
>>> configured correctly?
>>>>> -Erik
>>>>> ---------------------------------------------------------------- for
>>> list details see
>>>>> http://www.magnolia.info/en/community/developer/mailinglists.html
>>> ----------------------------------------------------------------
>>>>
>>>>
>>>> ---------------------------------------------------------------- for
>>> list details see
>>>> http://www.magnolia.info/en/community/developer/mailinglists.html
>>> ----------------------------------------------------------------
>>>>
>>>
>>>
>>> –
>>>
>>>
>>> Mvh,regards
>>>
>>>
>>> Kristoffer Moe
>>> Senior Consultant
>>> Net Consult AS
>>>



 Comments   
Comment by Sameer Charles [ 01/Feb/05 ]

Fixed on current trunk
http://svn.magnolia.info/svn/magnolia/trunk/src/main/info/magnolia/cms/core/CacheHandler.java
http://svn.magnolia.info/svn/magnolia/trunk/src/main/info/magnolia/cms/servlets/EntryServlet.java

Comment by Erik Gulliksen [ 01/Feb/05 ]

Sweet =)

Is it safe to use in 2.01 too?

Comment by Sameer Charles [ 01/Feb/05 ]

updated
http://svn.magnolia.info/svn/magnolia/trunk/src/main/info/magnolia/cms/core/CacheHandler.java

tested, it works for 2.0/2.01 as well, but you need to merge it.

changes:
New inner class of EntryServlet as proposed CacheRequest
check EntryServlet.doGet

that's all

Comment by Erik Gulliksen [ 01/Feb/05 ]

Works great =)
Here is my source file if anyone else miss it too..

Comment by Andreas Weder [ 01/Feb/05 ]

In order to retrofit this fix into the 2.01 code base, do I have to get CacheHandler from the trunk and the EntryServlet from you, Erik?

Also, if I put CacheHandler into my 2.01 code base, I do get errors (SecureURI does not exist).

Comment by Erik Gulliksen [ 02/Feb/05 ]

I use the "106 version" from 2.01 of CacheHandler (attatched too just in case). The new for 2.1 trunk is altered and u get the error with some class referances (I think they moved that class to a new package..?) Well anyway the 2 files attatched is what i used for a patch on 2.01.. Hope this clears it out =)

Comment by Andreas Weder [ 03/Feb/05 ]

I've checked your recommended version of CacheHandler with the one currently in 2.01. It looks like the two are equal. I thus only updated EntryServlet.

But I'm not sure this helped. I had caching turned on so far on my production machine. What I noticed was that the page seem to roughly take the same time to build as on the author instance. But at least it showed every time.

If I enable caching now, I get an empty page as soon as I hit the cache on the public instance. So something is wrong.

What could it be? I've activated caching by setting "active" to "true", and set "domain" to "localhost:8082". My public instance is indeed running on port 8082.

Comment by Sameer Charles [ 27/Apr/05 ]

on svn

Generated at Mon Feb 12 03:15:47 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.