velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Everett Toews <everett.to...@net-linx.com>
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.

Everett

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():
>
>java.lang.NullPointerException
>   at 
> org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:814)
>   at 
> org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:796)
>   at 
> org.apache.velocity.runtime.RuntimeSingleton.getTemplate(RuntimeSingleton.java:337)
>   at org.apache.velocity.app.Velocity.getTemplate(Velocity.java:512)
>   ...
>
>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:
>
>resource.loader=webapp
>webapp.resource.loader.class=org.apache.velocity.tools.view.servlet.WebappLoader
>webapp.resource.loader.path=WEB-INF/templates
>webapp.resource.loader.cache=true
>webapp.resource.loader.modifcationCheckInterval=0
>
>velocimacro.library=library.vm
>runtime.log=velocity.log
>
>
>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();
>
>
>Thanks,
>Everett
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: velocity-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Mime
View raw message