2011-10-17 15 views
6

Cuando instatiating velocidad me sale este error (publicado sólo el "causado por" -Mensajes):registro de errores en la velocidad en los sistemas Linux

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) 

Ésta es mi fragmento de código:

VelocityEngine ve = new VelocityEngine(); 
    ve.evaluate(context, writer, "org.apache.velocity.runtime.log.NullLogChute", this.templateString); 

En primero mi código era la siguiente:

runtimeServices = RuntimeSingleton.getRuntimeServices(); 
node = runtimeServices.parse(reader, templateName); 

en mi máquina de Windows que funciona bien, pero en los sistemas Linux (Ubuntu 10.04) no funciona. Esto post no me ayuda mucho, ya que no he encontrado ninguna pista de qué directorio tengo que dar permisos de escritura.

descubrí, que el siguiente código está trabajando también en máquinas Linux:

String logPath = request.getRealPath("/velocity.log"); 
RuntimeSingleton.setProperty(RuntimeConstants.RUNTIME_LOG, logPath); 
runtimeServices = RuntimeSingleton.getRuntimeServices(); 
node = runtimeServices.parse(reader, templateName); 

No es una muy buena solución, ya que nunca podía estar seguro, si tengo permiso de escritura en mi contexto real camino. Lo mejor sería, simplemente apagando el registro de Velocity.

¿Qué diferente configuración de registro diferente tengo que configurar? ¿El NullLogChute no funciona o lo uso de forma inapropiada?

¡Gracias de antemano!

Respuesta

0

Hola, el problema está en fs protegido con permiso de escritura. De hecho en su StackTrace tiene:

java.io.FileNotFoundException: velocity.log (Permission denied) 

decidir lo que es bueno donde se escribirá registro de la velocidad. Y dices una buena palabra, no puedes saber si en producción puedes escribir en una ruta específica. Por lo tanto, es mejor poner esa ruta en un archivo de propiedades que sysadmin puede modificar como lo desee.

Así que verifique esta mi respuesta a otra publicación si puede ayudarlo.

Enlace here

Cuestiones relacionadas