Migrated from
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.5</version>
to
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.7</version>
Upon the execution of following instruction
VelocityContext vc = getVelocityContext(valuesMap);
StringWriter writer = new StringWriter();
Velocity.evaluate(vc, writer, "[generate email processor - event id = " + event.getId() + "]", bodyTemplate);
I am getting
java.lang.NullPointerException
at org.apache.velocity.runtime.RuntimeInstance.parse(RuntimeInstance.java:1198)
at org.apache.velocity.runtime.RuntimeInstance.parse(RuntimeInstance.java:1181)
at org.apache.velocity.runtime.RuntimeInstance.evaluate(RuntimeInstance.java:1297)
at org.apache.velocity.runtime.RuntimeInstance.evaluate(RuntimeInstance.java:1265)
at org.apache.velocity.app.Velocity.evaluate(Velocity.java:180)
at net.nationalpayment.core.backend.GenerateMessageProcessor$EventProcessor.generateMessage(GenerateMessageProcessor.java:1361)
at net.nationalpayment.core.backend.GenerateMessageProcessor$EventProcessor.run(GenerateMessageProcessor.java:1155)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
java.lang.NullPointerException
at org.apache.velocity.runtime.RuntimeInstance.parse(RuntimeInstance.java:1198)
at org.apache.velocity.runtime.RuntimeInstance.parse(RuntimeInstance.java:1181)
at org.apache.velocity.runtime.RuntimeInstance.evaluate(RuntimeInstance.java:1297)
at org.apache.velocity.runtime.RuntimeInstance.evaluate(RuntimeInstance.java:1265)
at org.apache.velocity.app.Velocity.evaluate(Velocity.java:180)
at net.nationalpayment.core.backend.GenerateMessageProcessor$EventProcessor.generateMessage(GenerateMessageProcessor.java:1361)
at net.nationalpayment.core.backend.GenerateMessageProcessor$EventProcessor.run(GenerateMessageProcessor.java:1155)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
I am initializing the RuntimeSingleton once during the execution of application as below.
if(!RuntimeSingleton.isInitialized()) {
RuntimeSingleton.init();
}
Why am i getting the NullPointerException ?
In velocity (version 1.7). Properties have been externalize to a property file named velocity.property.
After specifying the below mentioned properties leaving all others with default values as per my requirement.The issue got resolved.
runtime.log = /tmp/velocity.log
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.