When instatiating Velocity I get this error (posted just the "caused by"-messages):
java.lang.RuntimeException: Velocity could not be initialized!
Caused by: org.apache.velocity.exception.VelocityException: Error initializing log: Failed to initialize an instance of org.apache.velocity.runtime.log.Log4JLogChute with the current runtime configuration.
Caused by: org.apache.velocity.exception.VelocityException: Failed to initialize an instance of org.apache.velocity.runtime.log.Log4JLogChute with the current runtime configuration.
Caused by: java.lang.RuntimeException: Error configuring Log4JLogChute :
Caused by: java.io.FileNotFoundException: velocity.log (Permission denied)
This is my code snippet:
VelocityEngine ve = new VelocityEngine();
ve.evaluate(context, writer, "org.apache.velocity.runtime.log.NullLogChute", this.templateString);
At first my code looked like this:
runtimeServices = RuntimeSingleton.getRuntimeServices();
node = runtimeServices.parse(reader, templateName);
On my Windows machine it works fine, but on Linux systems (ubuntu 10.04) it doesn't work. This post doesn't help me much, since I haven't found any clues which directory I have to give write-permissions.
I found out, that the following code is working also at Linux machines:
String logPath = request.getRealPath("/velocity.log");
RuntimeSingleton.setProperty( RuntimeConstants.RUNTIME_LOG, logPath );
runtimeServices = RuntimeSingleton.getRuntimeServices();
node = runtimeServices.parse(reader, templateName);
It is not a very nice solution, since I could never be sure, if I have write permission on my real context path. The best would be, just turning off logging of Velocity.
What different different logging configuration do I have to set? Is the NullLogChute
just not working or do I use it inappropriate?
Thanks in advance!