velocity初始化失败的错误

jfinal项目,使用的velocity;开发环境下没问题,放到线上后,因为linux下使用非root权限运行的 jvm,错误信息如下@JFinal

[ERROR]-[Thread: http-nio-8080-exec-14]-[com.jfinal.core.ActionHandler.handle()]: /login
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.
        at org.apache.velocity.runtime.RuntimeInstance.initializeLog(RuntimeInstance.java:875)
        at org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:262)
        at org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:646)
        at org.apache.velocity.runtime.RuntimeSingleton.init(RuntimeSingleton.java:226)
        at org.apache.velocity.app.Velocity.init(Velocity.java:97)
        at com.jfinal.render.VelocityRender.render(VelocityRender.java:93)
        at com.jfinal.core.ActionHandler.handle(ActionHandler.java:106)
        at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:89)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:475)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:341)
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:495)
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:767)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1354)
        at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.velocity.exception.VelocityException: Failed to initialize an instance of org.apache.velocity.runtime.log.Log4JLogChute with the current runtime configuration.
        at org.apache.velocity.runtime.log.LogManager.createLogChute(LogManager.java:220)
        at org.apache.velocity.runtime.log.LogManager.updateLog(LogManager.java:269)
        at org.apache.velocity.runtime.RuntimeInstance.initializeLog(RuntimeInstance.java:871)
        ... 25 more
Caused by: java.lang.RuntimeException: Error configuring Log4JLogChute :
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at org.apache.velocity.util.ExceptionUtils.createWithCause(ExceptionUtils.java:67)
        at org.apache.velocity.util.ExceptionUtils.createRuntimeException(ExceptionUtils.java:45)
        at org.apache.velocity.runtime.log.Log4JLogChute.initAppender(Log4JLogChute.java:133)
        at org.apache.velocity.runtime.log.Log4JLogChute.init(Log4JLogChute.java:85)
        at org.apache.velocity.runtime.log.LogManager.createLogChute(LogManager.java:157)
        ... 27 more
Caused by: java.io.FileNotFoundException: velocity.log (Permission denied)
        at java.io.FileOutputStream.open0(Native Method)
        at java.io.FileOutputStream.open(FileOutputStream.java:270)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:133)
        at org.apache.log4j.FileAppender.setFile(FileAppender.java:294)
        at org.apache.log4j.RollingFileAppender.setFile(RollingFileAppender.java:207)
        at org.apache.log4j.FileAppender.<init>(FileAppender.java:110)
        at org.apache.log4j.RollingFileAppender.<init>(RollingFileAppender.java:79)
        at org.apache.velocity.runtime.log.Log4JLogChute.initAppender(Log4JLogChute.java:118)
        ... 29 more



请问波总,这个问题要怎么处理呢?

评论区

JFinal

2019-03-27 07:18

纯文件访问权限问题,用 chmod 解决

热门反馈

扫码入社