What resource loader are you using?
We changed the way ClasspathResourceloader works in 1.5-dev.
If you're using ClasspathResourceloader, where is the velocity jar and where are your templates?
WILL
----- Original Message ----- From: <[EMAIL PROTECTED]>
To: "Velocity Users List" <velocity-user@jakarta.apache.org>
Sent: Wednesday, April 13, 2005 1:19 PM
Subject: Re: Problem with decimal in most recent snapshot
Ok I am back with another problem with trunk version I am currently trying to diagnose. When I use Velocity to merge a template on the web site, Velocity is acting correctly. When I am merging Velocity internally in a servlet to send formatted email, I am getting a NPE in velocity. When I go back to using 1.4, no NPE and email is sent perfectly. I need to do more diagnosis.
Template looks like: .... <body> #parse("$!header") #parse("$!body") #parse("$!footer") </body> ....
Email code looks like (no variables in context are null as show in error at bottom):
while (keys.hasNext())
{ // Making attributes available to the template.
key = (String)keys.next();
context.put(key, contextProperties.get(key));
System.err.println("VARIABLE PUT INTO CONTEXT: " + key + " = " + contextProperties.get(key));
}
}
StringWriter resultWriter = new StringWriter();
try { System.err.println("THE TEMPLATE PATH IS: " + templatePath); Template template = Velocity.getTemplate(templatePath); template.merge(context, resultWriter); }
VARIABLE PUT INTO CONTEXT: header = /WEB-INF/templates/pub/common/email/default/defaultEmailMenuHeader.vm
VARIABLE PUT INTO CONTEXT: footer = /WEB-INF/templates/pub/common/email/default/defaultEmailMenuFooter.vm
VARIABLE PUT INTO CONTEXT: requestData = [GuestFName GuestLName|http://www.jb.com/action/pub/member/receiveemailconfirmation/setup?email=lavalamp%jb.com&mid=10001]
VARIABLE PUT INTO CONTEXT: body = /WEB-INF/templates/pub/member/registration/emailregconfirm.vm
THE TEMPLATE PATH IS: /WEB-INF/templates/pub/common/email/default/defaultEmailTemplate.vm
ERROR [http8080-Processor2] TemplateToStringManagerBD.getContentAsString() - VelocityEngine failed to merge the template.
java.lang.NullPointerException
at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:835)
at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:817)
at org.apache.velocity.runtime.RuntimeSingleton.getTemplate(RuntimeSingleton.java:285)
at org.apache.velocity.app.Velocity.getTemplate(Velocity.java:469)
at com.jb.commonmvc.view.template.velocity.TemplateToStringManagerBD.getContentAsString(TemplateToStringManagerBD.java:120)
at com.jb.commonmvc.transport.email.EmailTemplate.emailTemplate(EmailTemplate.java:37)
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]