velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Will Glass-Husain" <wglasshus...@gmail.com>
Subject Re: Template cache _kinda_ works?
Date Mon, 07 May 2007 22:23:02 GMT
maybe you have multiple copies of the jar file as you suggest?

I've had problems before (with other libraries) with things working when at
a break point but not while running continuously.  it turned out that one
classpath was active at the break and a different one while running.

be interesting to do a print/log statement while running to see if you have
the same results (rather than breaking and manually checking).

Full dependency version info at:
http://velocity.apache.org/engine/releases/velocity-1.5/build.html

WILL

On 5/7/07, Bensman, Jeff [EESUS Non J&J] <JBensma1@eesus.jnj.com> wrote:
>
> Will,
>
> Thank you for taking the time to put together the sample project.  I've
> run
> that in my environment, and as you say, it runs as expected!
>
> Per your initial questions, I have not changed the max size of the cache.
>
> I am running in a web app, but I'm confident it's not a caching issue on
> the
> browser.  I'm stepping through the source code, including velocity source
> code, in the Eclipse debugger on Tomcat 5.5.
>
> After an edit to my template, the Modified Date shown in Windows Explorer
> is
> updating.  If I set a breakpoint in the isSourceModified() method of
> Velocity's FileResourceLoader, it properly returns true after an edit to
> the
> template.  And then at another breakpoint in the merge() method of
> Template,
> I look at a toString() on the "data" property of the Template class, and
> it
> shows the new, edited template content.  But within that merge() method,
> the
> line that reads:
>     ( (SimpleNode) data ).render( ica, writer);
> seems to result in a writer that holds an old version of the template,
> ignoring the new stuff in the "data" property of the Template.
>
> I get a little lost trying to step through that render() method.  Can you
> recommend any key things I could look at that might reveal what's
> happening?
>
> On a different note, here are the differences I noticed between your
> VelocityWebTest test project and my project...
>
> 1) your template is inside the file system of your web app, mine is not
> 2) you're using the version of the velocity JAR with dependencies, my app
> has the dependencies separate from the velocity jar
> 3) when I set the velocity properties before init() I specify a
> "velocimacro.library" (which works fine)
>
> But for all 3 cases I modified my app to be configured/run like yours, and
> it made no difference.
>
> I've had a co-worker look over my shoulder to make sure I'm not doing
> something insanely stupid, but if I am, he's not seeing it either.
>
> The only thing I can think of, that I've not had the time to fully explore
> yet, is that one of dependency jar files in my application is at fault.
> Perhaps I'm on a wrong version of one of the dependencies and it's getting
> picked up, even when using the full velocity-dep-1.5.jar jar.  (I have a
> dependency on commons-collections, even outside of the use of Velocity).
> This page:
> http://velocity.apache.org/engine/devel/jar-dependencies.html
> lists the dependencies but doesn't give version numbers.  Are version
> numbers listed somewhere that I'm missing?
>
> Thanks for your help.
>
> Jeff
>
>
>
> -----Original Message-----
> From: Will Glass-Husain [mailto:wglasshusain@gmail.com]
> Sent: Sunday, May 06, 2007 11:01 AM
> To: Velocity Users List
> Subject: Re: Template cache _kinda_ works?
>
>
> [my original note got rejected as spam.  removing the attachment, seeing
> if
> that helps]
>
> ---------- Forwarded message ----------
> From: Will Glass-Husain <wglasshusain@gmail.com>
> Date: May 6, 2007 7:56 AM
> Subject: Re: Template cache _kinda_ works?
> To: Velocity Users List <user@velocity.apache.org>, "Bensman, Jeff [EESUS
> Non J&J]" <JBensma1@eesus.jnj.com>
>
> Hi Jeff,
>
> I built a small test servlet to check this and had no problems.  I used
> the
> StringWriter just as you described.  I displayed a file, changed it, and
> refreshed the page.  When I refreshed in less than 10 seconds it showed
> the
> old text.  When I refreshed after 10 seconds, it showed the new text.
>
> How are you changing the file?  Obviously, the file timestamp has to
> change
> for Velocity to notice it is new.
>
> Also - is this a web app?  Are you sure it's just not something silly like
> a
> browser cache of the page?
>
> (Test code attached, though it'll probably get stripped by the list serv).
>
> WILL
>
>
> On 5/4/07, Bensman, Jeff [EESUS Non J&J] < JBensma1@eesus.jnj.com> wrote:
> >
> > I've got the Velocity 1.5 engine integrated into my application's code
> and
> > everything seemed to be going great.  But then, I noticed that template
> > caching is only _kinda_ working.
> >
> > I've stepped through the Velocity source code to verify that my template
> > object is correctly reloading when modified (I'm using
> > FileResourceLoader).
> > By verify, I mean that I can see that the ResourceLoader's isCachingOn()
> > is
> > correctly returning true and the class's modificationCheckInterval
> > reflects
> > my property setting (10 seconds).  And if I...
> >
> > - call Velocity.getTemplate(String name)
> > - run a merge( Context context, Writer writer) on the returned template
> > - go out to the file system and edit the template file (after waiting 10
> > seconds)
> > - and then re-run the Velocity.getTemplate()
> >
> > ...I see that the Template object I get from getTemplate() the second
> > time,
> > reflects the file system change I made (Yeah!), because its data
> property
> > is
> > holding my new stuff.  BUT, when I call merge on it, the StringWriter I
> > get
> > back reflects the old state of the template, before my change!
> >
> > Here's my code:
> >
> > public static String buildView(String templateName, Map templateData )
> > throws Exception {
> >     VelocityContext velocityContext = new VelocityContext(templateData);
> >     Template velocityTemplate = Velocity.getTemplate(templateName);
> >     StringWriter stringWriter = new StringWriter();
> >     velocityTemplate.merge( velocityContext, stringWriter );
> >     return stringWriter.toString();
> > }
> >
> > What am I missing?  I went back to Velocity 1.4 to make sure it wasn't
> > some
> > new bug in 1.5, but 1.4 behaves the same way.
> >
> > Thanks for any help,
> >
> > Jeff
> >
> >
>
>
> --
> Forio Business Simulations
>
> Will Glass-Husain
> wglass@forio.com
> www.forio.com
>
>
>
> --
> Forio Business Simulations
>
> Will Glass-Husain
> wglass@forio.com
> www.forio.com
>



-- 
Forio Business Simulations

Will Glass-Husain
wglass@forio.com
www.forio.com

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message