При установке Velocity я получаю эту ошибку (публикуется только сообщение «вызвано»):
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)
Это мой фрагмент кода:
VelocityEngine ve = new VelocityEngine();
ve.evaluate(context, writer, "org.apache.velocity.runtime.log.NullLogChute", this.templateString);
Сначала мой код выглядел так:
runtimeServices = RuntimeSingleton.getRuntimeServices();
node = runtimeServices.parse(reader, templateName);
На моей машине с Windows это работает нормально, но в системах Linux (Ubuntu 10.04) это не работает. Эта запись мне мало помогает, так как я не нашел никаких подсказок, какой каталог я должен дать разрешения на запись.
Я обнаружил, что следующий код работает и на машинах Linux:
String logPath = request.getRealPath("/velocity.log");
RuntimeSingleton.setProperty( RuntimeConstants.RUNTIME_LOG, logPath );
runtimeServices = RuntimeSingleton.getRuntimeServices();
node = runtimeServices.parse(reader, templateName);
Это не очень хорошее решение, поскольку я никогда не смогу быть уверенным, если у меня есть разрешение на запись в моем реальном пути к контексту. Лучше всего было бы просто отключить ведение журнала Velocity.
Какую другую конфигурацию регистрации я должен установить? NullLogChute
просто не работает или мне его неуместно использовать?
Заранее спасибо!