[ http://issues.apache.org/jira/browse/VELOCITY-374?page=all ]
Will Glass-Husain updated VELOCITY-374:
---------------------------------------
Bugzilla Id: (was: 34478)
Fix Version: 1.5
Description:
VelocityEngine throws a strange NPE if it's not initialized. It'd be better
if it threw an Exception with a meaningful error message.
>From [EMAIL PROTECTED] <[EMAIL PROTECTED]>
I had another problem that I think can help others in the future. In looking
through the archives I noticed other people having the same null pointer
exception I was having. I went through the code and noticed that if a person
did not "init()" a velocity engine, the resourceManager never gets
initialized. When they call the function below in RuntimeInstance.java, they
get the null pointer exception.
public Template getTemplate(String name, String encoding)
throws ResourceNotFoundException, ParseErrorException, Exception
{
return (Template)
resourceManager.getResource(name,
ResourceManager.RESOURCE_TEMPLATE, encoding);
}
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.getContentAsS
tring(TemplateToStringManagerBD.java:120)
at com.jb.commonmvc.transport.email.EmailTemplate.emailTemplate
(EmailTemplate.java:37)
was:
VelocityEngine throws a strange NPE if it's not initialized. It'd be better
if it threw an Exception with a meaningful error message.
>From [EMAIL PROTECTED] <[EMAIL PROTECTED]>
I had another problem that I think can help others in the future. In looking
through the archives I noticed other people having the same null pointer
exception I was having. I went through the code and noticed that if a person
did not "init()" a velocity engine, the resourceManager never gets
initialized. When they call the function below in RuntimeInstance.java, they
get the null pointer exception.
public Template getTemplate(String name, String encoding)
throws ResourceNotFoundException, ParseErrorException, Exception
{
return (Template)
resourceManager.getResource(name,
ResourceManager.RESOURCE_TEMPLATE, encoding);
}
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.getContentAsS
tring(TemplateToStringManagerBD.java:120)
at com.jb.commonmvc.transport.email.EmailTemplate.emailTemplate
(EmailTemplate.java:37)
Environment:
Operating System: other
Platform: Other
was:
Operating System: other
Platform: Other
Assign To: (was: Velocity-Dev List)
> VE throws NPE if not initialized
> --------------------------------
>
> Key: VELOCITY-374
> URL: http://issues.apache.org/jira/browse/VELOCITY-374
> Project: Velocity
> Type: Bug
> Components: Source
> Versions: 1.5
> Environment: Operating System: other
> Platform: Other
> Reporter: Will Glass-Husain
> Fix For: 1.5
>
> VelocityEngine throws a strange NPE if it's not initialized. It'd be better
> if it threw an Exception with a meaningful error message.
> From [EMAIL PROTECTED] <[EMAIL PROTECTED]>
> I had another problem that I think can help others in the future. In looking
> through the archives I noticed other people having the same null pointer
> exception I was having. I went through the code and noticed that if a person
> did not "init()" a velocity engine, the resourceManager never gets
> initialized. When they call the function below in RuntimeInstance.java, they
> get the null pointer exception.
> public Template getTemplate(String name, String encoding)
> throws ResourceNotFoundException, ParseErrorException, Exception
> {
> return (Template)
> resourceManager.getResource(name,
> ResourceManager.RESOURCE_TEMPLATE, encoding);
> }
> 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.getContentAsS
> tring(TemplateToStringManagerBD.java:120)
> at com.jb.commonmvc.transport.email.EmailTemplate.emailTemplate
> (EmailTemplate.java:37)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]