When instatiating Velocity I get this error (only the message "caused" is posted):
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 piece of code:
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);
It works fine on my Windows machine, but it doesn't work on Linux systems (ubuntu 10.04). This post does not help me much, since I did not find any clues in which directory I should grant write permissions.
I found out that the following code works on Linux machines too:
String logPath = request.getRealPath("/velocity.log"); RuntimeSingleton.setProperty( RuntimeConstants.RUNTIME_LOG, logPath ); runtimeServices = RuntimeSingleton.getRuntimeServices(); node = runtimeServices.parse(reader, templateName);
This is not a good solution, since I was never sure if I have write permission in my real context. It would be best to just turn off Velocity logging.
What other registration configuration should I install? Is NullLogChute just not NullLogChute or am I not using it?
Thanks in advance!
Franz source share