При инициализации 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
просто не работает или я использую его не по назначению?
Заранее спасибо!