velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Everett Toews <>
Subject Re: Strange NPE on call to Velocity.getTemplate()
Date Wed, 02 Apr 2003 21:31:24 GMT
The problem seems to have righted itself.  I noticed I stopped getting this 
behaviour when I restarted the JBoss/Tomcat I was running 
(jboss-3.0.4_tomcat-4.1.12).  When you do a lot of redeploying, as I was 
doing, you eventually get an OutOfMemory with this version of JBoss (at 
least I do) and you have to restart JBoss.  Maybe this had something to do 
with my NPE problem below.


At 11:03 AM Wednesday 4/2/2003, you wrote:
>Hi all,
>I'm getting this NPE when I make a call to Velocity.getTemplate():
>   at 
> org.apache.velocity.runtime.RuntimeInstance.getTemplate(
>   at 
> org.apache.velocity.runtime.RuntimeInstance.getTemplate(
>   at 
> org.apache.velocity.runtime.RuntimeSingleton.getTemplate(
>   at
>   ...
>What makes this odd is that this happens only the very first time this 
>template is used.  On any following uses of this template it works fine 
>without complaint, no exceptions and no problems in the log file.  Even 
>stranger is that 5 other templates are parsed and used with no problem 
>before the template that causes this problem.  Has anyone run into this 
>behaviour or know what to do about it?
>I'm using velocity-dep-1.3.1.jar and velocity-tools-view-0.8.jar and I am 
>calling Velocity.init() before using any templates.  These are the 
>properties I'm using:
>The code that uses this template is:
>StringWriter result = new StringWriter();
>try {
>   VelocityContext context = new VelocityContext();
>   context.put("currPage", new Integer(currPage));
>   context.put("numPages", new Integer(numPages));
>   Template template = Velocity.getTemplate("pager.vm");
>   template.merge(context, result);
>} catch (Exception e) {
>   e.printStackTrace();
>   result.write("The following error occured rendering the pager: " + 
> e.getMessage());
>return result.toString();
>To unsubscribe, e-mail:
>For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message