Re: ClassCastException and Server Crash when using MruCacheStorage

Attila Szegedi <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
Once you have a stack trace, you might want to switch to use the SoftCacheStorage class, as it probably doesn't exhibit the problem - since you're using maxStrongSize=0 with MruCacheStorage anyway, the behavior should be identical to MruCacheStorage. That should help you until we can fix the problem (once it was identified by a stack trace).

Attila.

On Mar 23, 2011, at 8:09 AM, Ram Palagummi wrote:

> Daniel,
> 
> To help understand our application better :
> Our application is full of web pages and we are looking at more than 150,000 pages (including all locales) overall. We have a master ftl file which is considered a layout file that freemarker picks-up no matter what the requested page is and starts including the actual requested page inside that master ftl, i.e., for every web page requested, freemarker will pick master ftl layout file and include an html file (which is core content body page) inside it and starts processing. So the ftl is only one but the html files are a lot that are around 150,000 on the file system. In our case, all these html files are considered freemarker templates. But at any point in time, there could be 2500 to may be 8000 of those files that are served by the application server under load.   
> 
> We realized that the performance is greatly improved with CacheStorage but not sure if it helps setting maxStrongSize to a non-0 number. We do not have any other caching configured for these templates (which are huge number of html files in our case). 
> 
> We definitely agree with you regarding the MruCacheStorage not throwing any errors, but anytime the server stops responding, we are seeing enormous number of errors being logged that point to the MruCacheStorage$MruReference error indicated below. We are working on getting the complete stack trace to understand this so I will check back with you when we have it. 
> 
> All we did in using FreeMarker is Spring configuration (shown below) and no additional coding to handle MruCacheStorage. Based on your input, we will look into entire code and see if there is anything we have done wrong that's causing this issue. 
> 
> <bean id="freemarkerConfig"
>                 class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
>                 <property name="configuration">
>                         <ref local="customFreemarkerConfig" />
>                 </property>
>         </bean>
>  
> <bean id="customFreemarkerConfig"
>                 class="com.emc.oneemc.freemarker.FreemarkerConfig">
>                 <property name="objectWrapper">
>                         <ref local="beansWrapper" />
>                 </property>
>                 <property name="defaultEncoding" value="UTF-8" />
>                 <property name="localizedLookup" value="false" />
>                 <property name="templateUpdateDelay" value="60" />
>                 <property name="cacheStorage">
>                         <ref local="cacheStorage" />
>                 </property>
>  
>                 <property name="multiTemplatePath">
>                         <list>
>                                 <value>DOC_TARGET_A</value>
>                         </list>
>                 </property>
>         </bean>
>  
>         <bean id="cacheStorage" class="freemarker.cache.MruCacheStorage">
>                 <constructor-arg index="0" value="0" />
>                 <constructor-arg index="1" value="2500" />
>         </bean>
> 
> 
> Thanks
> Ram
> 
> 
> 
> From: Daniel Dekany <[email protected]>
> To: Ram Palagummi <[email protected]>
> Cc: Attila Szegedi <[email protected]>
> Sent: Wed, March 23, 2011 4:40:54 AM
> Subject: Re: [FreeMarker-user] ClassCastException and Server Crash when using MruCacheStorage
> 
> Wednesday, March 23, 2011, 4:40:00 AM, Ram Palagummi wrote:
> 
> > Hi Daniel,
> >
> > While we are trying to reproduce the problem with full debugging
> > turned on, could you please recommend maxStrongSize and maxSoftSize
> > settings for our application? Basically, our application is a public
> > facing (www.emc.com) where we have a master template that loads
> > every page upon request. In other words, every page then becomes a
> > template from FreeMarker perspective.
> 
> How many templates do you have? That's what mainly matters as far as
> the cache size is concerned. When I ask "how many templates", what
> counts is the .ftl files (or however you store them), not their
> output.
> 
> > Any URL that's requested on our site is a template with JSP tags in them.
> >
> > Our goal is to make sure that most recently visited pages are not
> > loaded every time and hence we set the maxStrongSize = 0 and
> > maxSoftSize = 2500.
> 
> If you have less than 2500 templates, it should give a good
> performance, except if some other components like to make many
> soft-referenced objects too, or if your application tends to exhaust
> the heap size in general. In that case you better set maxStrongSize to
> the number of frequently used templates and decrease maxSoftSize with
> that amount.
> 
> > I am not sure if these settings are really serving the purpose as we
> > do see ERRORs rising from MruCacheStorage class forcing us to
> > restart the servers (I will definitely send the full stack trace as
> > soon as we have it).
> 
> MruCacheStorage should never throw any exceptions, no mater how badly
> it was configured. (Well, unless you have like thousands of different
> templates what will be all strong-cached and you run out of memory, of
> course. But that's not a ClassCastException.)
> 
> > As FreeMarker is slowly  becoming becoming a standard in several of
> > our applications at EMC, I need your help to recommend the best practices.
> >
> > Lastly, is there a formal support from FreeMarker that we can engage at this point?
> >
> > Thanks & Best Regards
> > Ram
> >
> > From: Ram Palagummi <[email protected]>
> > To: Daniel Dekany <[email protected]>
> > Cc: Attila Szegedi <[email protected]>; FreeMarker-user
> > <[email protected]>
> > Sent: Tue, March 22, 2011 11:50:38 AM
> > Subject: Re: [FreeMarker-user] ClassCastException and Server Crash when using MruCacheStorage
> >
> > I have requested our middle-ware team to turn the complete
> > debugging on. We'll let you know as soon as this issue surfaces again. But it will very soon.
> >
> > As you can see from the errors below, when the server stops
> > responding, the last thing we notice are the MruCacheStorage errors being logged.
> >
> > I'll keep you posted.
> >
> > Thanks for looking into this issue.
> > Best Regards
> > Ram
> >  
> >
> > From: Daniel Dekany <[email protected]>
> > To: Ram Palagummi <[email protected]>
> > Cc: Attila Szegedi <[email protected]>; FreeMarker-user
> > <[email protected]>
> > Sent: Tue, March 22, 2011 11:30:33 AM
> > Subject: Re: [FreeMarker-user] ClassCastException and Server Crash when using MruCacheStorage
> >
> > No stack trace? /-:
> >
> >
> > Tuesday, March 22, 2011, 5:25:11 PM, Ram Palagummi wrote:
> >
> >> Hi Attila,
> >>
> >> Please see below the error messages. It seems evident that the
> >> error is caused due to MruCacheStorage access for a template. Please
> >> let me know if there is anything I can provide to help you. 
> >>
> >> After getting these message for a while, we are forced to restart the servers.
> >>
> >> 2011-03-19 00:31:22,135 ERROR
> >> com.emc.oneemc.web.view.EMCFreemarkerView - method: renderMergedTemplateModel
> >> message: ERROR while processing freemarker template:
> >> java.lang.ClassCastException:
> >> freemarker.cache.MruCacheStorage$MruReference
> >> 2011-03-19 00:31:23,300 ERROR
> >> com.emc.oneemc.web.view.EMCFreemarkerView - method: renderMergedTemplateModel
> >> message: ERROR while processing freemarker template:
> >> java.lang.ClassCastException:
> >> freemarker.cache.MruCacheStorage$MruReference
> >> 2011-03-19 00:31:24,943 ERROR
> >> com.emc.oneemc.web.view.EMCFreemarkerView - method: renderMergedTemplateModel
> >> message: ERROR while processing freemarker template:
> >> java.lang.ClassCastException:
> >> freemarker.cache.MruCacheStorage$MruReference
> >> 2011-03-19 00:31:25,623 ERROR
> >> com.emc.oneemc.web.filter.URLProcessingFilter - method: getLocaleForDomain()
> >> message: Locale not exist for domain
> >> :www.informationwatch.net....... Setting to US locale
> >> 2011-03-19 00:31:25,639 ERROR
> >> com.emc.oneemc.web.view.EMCFreemarkerView - method: renderMergedTemplateModel
> >> message: ERROR while processing freemarker template:
> >> java.lang.ClassCastException:
> >> freemarker.cache.MruCacheStorage$MruReference
> >> 2011-03-19 00:31:26,244 ERROR
> >> com.emc.oneemc.web.view.EMCFreemarkerView - method: renderMergedTemplateModel
> >> message: ERROR while processing freemarker template:
> >> java.lang.ClassCastException:
> >> freemarker.cache.MruCacheStorage$MruReference
> >> 2011-03-19 00:31:26,759 ERROR
> >> com.emc.oneemc.web.view.EMCFreemarkerView - method: renderMergedTemplateModel
> >> message: ERROR while processing freemarker template:
> >> java.lang.ClassCastException:
> >> freemarker.cache.MruCacheStorage$MruReference
> >> 2011-03-19 00:31:26,814 ERROR
> >> com.emc.oneemc.web.view.EMCFreemarkerView - method: renderMergedTemplateModel
> >> message: ERROR while processing freemarker template:
> >> java.lang.ClassCastException:
> >> freemarker.cache.MruCacheStorage$MruReference
> >> 2011-03-19 00:31:26,954 ERROR
> >> com.emc.oneemc.web.view.EMCFreemarkerView - method: renderMergedTemplateModel
> >> message: ERROR while processing freemarker template:
> >> java.lang.ClassCastException:
> >> freemarker.cache.MruCacheStorage$MruReference
> >> <Mar 19, 2011 12:31:27 AM EDT> <Alert> <WebLogicServer>
> >> <BEA-000396> <Server shutdown has been requested by weblogic> 
> >> <Mar 19, 2011 12:31:27 AM EDT> <Notice> <WebLogicServer>
> >> <BEA-000365> <Server state changed to FORCE_SUSPENDING> 
> >> <Mar 19, 2011 12:31:28 AM EDT> <Notice> <WebLogicServer>
> >> <BEA-000365> <Server state changed to ADMIN> 
> >> <Mar 19, 2011 12:31:28 AM EDT> <Notice> <WebLogicServer>
> >> <BEA-000365> <Server state changed to FORCE_SHUTTING_DOWN> 
> >> <Mar 19, 2011 12:31:28 AM EDT> <Notice> <Server> <BEA-002607>
> >> <Channel "Default" listening on 128.221.59.51:7012 was shutdown.> 
> >> <Mar 19, 2011 12:31:28 AM EDT> <Notice> <Server> <BEA-002607>
> >> <Channel "Default[1]" listening on 127.0.0.1:7012 was shutdown.> 
> >>
> >>
> >> Thanks
> >> Ram
> >>
> >> From: Attila Szegedi <[email protected]>
> >> To: FreeMarker-user <[email protected]>
> >> Cc: Ram Palagummi <[email protected]>
> >> Sent: Mon, March 21, 2011 2:33:19 PM
> >> Subject: Re: [FreeMarker-user] ClassCastException and Server Crash when using MruCacheStorage
> >>
> >> Can you capture a full stack trace? 
> >>
> >> On Mar 21, 2011, at 11:32 AM, Ram Palagummi wrote:
> >>
> >> Hi,
> >>
> >> I am an architect from EMC corporation and we have been using
> >> FreeMarker for rendering our emc.com and few other application web
> >> pages. We deployed new EMC.com towards the end of 2007 and the
> >> FreeMarker version we went live with is 2.3.10.
> >>
> >> We have been noticing that anytime  MruCacheStorage (strong = 0 and
> >> soft=500 or any other settings) is turned on for template caching,
> >> we are getting the following error and the servers have to be
> >> bounced in order to fix the problem. 
> >>
> >> ERROR while processing freemarker
> >> template:java.lang.CLassCastException :
> >> freemarker.cache.MruCacheStorage$MruReference.
> >>
> >> Additionally, we are seeing the intermittent 404 issues when
> >> freemarker is trying to load template from its cache causing panic within our user community.
> >>
> >> Its critical that we resolve this issue right away. Please let us
> >> know if this is a known issue and has a fix. 
> >>
> >> Thanks
> >> Solution Architect 
> >> EMC Corporation
> >
> 
> -- 
> Best regards,
> Daniel Dekany
> 
> 
>

------------------------------------------------------------------------------
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software 
be a part of the solution? Download the Intel(R) Manageability Checker 
today! http://p.sf.net/sfu/intel-dev2devmar

_______________________________________________
FreeMarker-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.