Reputation: 165
When I call Velocity.init() I get the following exception. I have included all dependencies, I have tried setting properties and using property files but all to no avail. any help?
Exception in thread "main" java.lang.NullPointerException
at java.io.Reader.<init>(Reader.java:78)
at java.io.InputStreamReader.<init>(InputStreamReader.java:97)
at org.apache.commons.collections.ExtendedProperties.load(ExtendedProperties.java:543)
at org.apache.commons.collections.ExtendedProperties.load(ExtendedProperties.java:519)
at org.apache.velocity.runtime.RuntimeInstance.setDefaultProperties(RuntimeInstance.java:416)
at org.apache.velocity.runtime.RuntimeInstance.initializeProperties(RuntimeInstance.java:628)
at org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:261)
at org.apache.velocity.runtime.RuntimeSingleton.init(RuntimeSingleton.java:112)
at org.apache.velocity.app.Velocity.init(Velocity.java:74)
here is the calling code
import com.syntatik.roborm.RobormEntity;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.Template;
import org.apache.velocity.app.Velocity;
import java.io.BufferedWriter;
import java.io.OutputStreamWriter;
import java.util.Properties;
public class Generator{
protected VelocityContext context;
public Generator(){
Velocity.init();
this.context = new VelocityContext();
}
}
Upvotes: 1
Views: 1496
Reputation: 19443
I have looked at the Velocity source code and can see that it's finding the default properties file on your classpath and then it's having trouble in Reader.java. With an IDE you should be able to get the source to Reader.java to find out why it's getting the NPE. Unfortunately at the moment I can't look at Reader
to give you more information.
If you can't determine the cause of the NPE, I suggest you delete the default property file from your classpath and set the properties in code.
Have a look at this question for more information
Upvotes: 2