Could not initialize class org.apache.log4j.LogManager 报错
部署项目的时候,在windows下一切正常,但是在centos下就发生如下错误
Caused by: java.lang.ExceptionInInitializerError
at com.dsideal.sys.service.impl.SysMenuService.<init>(SysMenuService.java:60)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:96)
... 32 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'LoggingThrowsAdvice' defined in class path resource [applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.dsideal.framework.aop.LoggingThrowsAdvice]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.apache.log4j.LogManager
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:881)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:837)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:440)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:220)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.dsideal.framework.common.SpringUtil.<clinit>(SpringUtil.java:9)
... 38 more
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.dsideal.framework.aop.LoggingThrowsAdvice]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.apache.log4j.LogManager
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:111)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:61)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:875)
... 54 more
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.apache.log4j.LogManager
at org.apache.log4j.Logger.getLogger(Logger.java:85)
at com.dsideal.framework.aop.LoggingThrowsAdvice.<init>(LoggingThrowsAdvice.java:12)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:96)
... 56 more
最终解决方法是:log4j.properties配置错误
windows下配置为:
#log4j.rootLogger=info,stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.conversionPattern=%5p [%t] - %m%n
#
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=c:/subject.log
log4j.appender.file.MaxFileSize=100KB
log4j.appender.file.MaxBackupIndex=0
log4j.appender.file.layout=org.apache.log4j.SimpleLayout
log4j.appender.file.layout.ConversionPattern=[ssh] %p %t %c - %m%n
#
log4j.logger.com.ibatis=debug,ibatis
log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=debug,ibatis
log4j.logger.com.ibatis.common.jdbc.ScriptRunner=debug,ibatis
log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=debug,ibatis
#
log4j.logger.java.sql.Connection=debug,ibatis
log4j.logger.java.sql.Statement=debug,ibatis
log4j.logger.java.sql.PreparedStatement=debug,stdout,ibatis
log4j.logger.java.lang.Exception=debug,ibatis
#
log4j.appender.ibatis=org.apache.log4j.RollingFileAppender
log4j.appender.ibatis.File=c:/ibatis.log
log4j.appender.ibatis.MaxFileSize=100KB
log4j.appender.ibatis.MaxBackupIndex=0
log4j.appender.ibatis.layout=org.apache.log4j.SimpleLayout
log4j.appender.ibatis.layout.ConversionPattern=[ssh] %p %t %c - %m%n log4j.logger.com.opensymphony.xwork2=ERROR
而在centos中,没有c:/,这里一定要注意
#log4j.rootLogger=info,stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.conversionPattern=%5p [%t] - %m%n
#
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=/usr/local/subject.log
log4j.appender.file.MaxFileSize=100KB
log4j.appender.file.MaxBackupIndex=0
log4j.appender.file.layout=org.apache.log4j.SimpleLayout
log4j.appender.file.layout.ConversionPattern=[ssh] %p %t %c - %m%n
#
log4j.logger.com.ibatis=debug,ibatis
log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=debug,ibatis
log4j.logger.com.ibatis.common.jdbc.ScriptRunner=debug,ibatis
log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=debug,ibatis
#
log4j.logger.java.sql.Connection=debug,ibatis
log4j.logger.java.sql.Statement=debug,ibatis
log4j.logger.java.sql.PreparedStatement=debug,stdout,ibatis
log4j.logger.java.lang.Exception=debug,ibatis
#
log4j.appender.ibatis=org.apache.log4j.RollingFileAppender
log4j.appender.ibatis.File=/usr/local/ibatis.log
log4j.appender.ibatis.MaxFileSize=100KB
log4j.appender.ibatis.MaxBackupIndex=0
log4j.appender.ibatis.layout=org.apache.log4j.SimpleLayout
log4j.appender.ibatis.layout.ConversionPattern=[ssh] %p %t %c - %m%n log4j.logger.com.opensymphony.xwork2=ERROR
Could not initialize class org.apache.log4j.LogManager 报错的更多相关文章
- java.lang.NoClassDefFoundError: Lorg/apache/log4j/Logger报错
java.lang.NoClassDefFoundError: Lorg/apache/log4j/Logger报错 错误提示: java.lang.NoClassDefFoundError: Lor ...
- Maven项目java.lang.NoClassDefFoundError: Lorg/apache/log4j/Logger报错
本文转载自:http://www.javaweb1024.com/info/894.jspx maven管理的项目,里面已经引入了log4j的包 maven引入如下: <dependency&g ...
- apache无法启动报错No space left on device
apache无法启动报错No space left on device 故障现象:apache无法启动ipcs信号量很多 # service httpd startStarting httpd : [ ...
- Apache Log4j 2 报高危漏洞,CODING 联手腾讯安全护卫软件安全
导语 12 月 9 日晚间,Apache Log4j 2 发现了远程代码执行漏洞,恶意使用者可以通过该漏洞在目标服务器上执行任意代码,危害极大. 腾讯安全第一时间将该漏洞收录至腾讯安全漏洞特征库中,C ...
- Apache无法启动报错查看
wampserver橙色图标 查找原因 1.测试80端口 . 如已被占用,则改别的端口在启动apache.怎么改apache的的端口去百度一下都有. 2.找到httpd.exe的目录.在cmd命令行下 ...
- apache状态显示报错AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdo...is message
今天启动apache查看状态发现报错,说不能确认服务器完全确认域名,以下是报错内容: [root@localhost ~]# service httpd status Redirecting to / ...
- windows安装Apache HTTP服务器报错:无法启动,因为应用程序的并行配置不正确
Apache HTTP服务器安装后报:无法启动,因为应用程序的并行配置不正确-(已解决) 0条评论 [摘要:本创做品,出自 “深蓝的blog” 专客,迎接转载,转载时请务必说明出处,不然有权穷究版 ...
- org.apache.catalina.LifecycleException报错解决方法
严重: A child container failed during startjava.util.concurrent.ExecutionException: org.apache.catalin ...
- 解决:java.lang.ClassNotFoundException: org.apache.xmlbeans.XmlObject报错问题。
利用POI操作PPT一直报如下错误java.lang.ClassNotFoundException: org.apache.xmlbeans.XmlObject 是因为项目中缺少一个包xmlbeans ...
随机推荐
- 6个常见的 PHP 安全性攻击
了解常见的PHP应用程序安全威胁,可以确保你的PHP应用程序不受攻击.因此,本文将列出 6个常见的 PHP 安全性攻击,欢迎大家来阅读和学习. 1.SQL注入 SQL注入是一种恶意攻击,用户利用在表单 ...
- Emmet(前身是zen coding)介绍和使用
Zen coding - 一种快速编写HTML/CSS代码的方法.它使用仿CSS选择器的语法来快速开发HTML和CSS - 由Sergey Chikuyonok开发. 现在它改名为了Emmet,并且搭 ...
- IPv6 tutorial 3 New features: IPsec and LAN features
https://4sysops.com/archives/ipv6-tutorial-part-3-new-features-ipsec-and-lan-features/ In the last p ...
- C# Word 类库的深入理解
using System;using System.Collections.Generic;using System.Text;using Microsoft.Office.Interop.Word; ...
- Android 实用代码七段(三)
前言 终于又攒了一篇出来,本系列以实用为主,欢迎和我分享和推荐好用的代码段~~ 声明 欢迎转载,但请保留文章原始出处:) 博客园:http://www.cnblogs.com 农民伯伯: http: ...
- 两个结构体ifconf和ifreq
用ioctl获得本地ip地址时要用到两个结构体ifconf和ifreq,它们对于大多数人来说都是比较陌生的,这里给大家一种比较简单的理解方法,当然只一种帮助理解的方法,在描述中可能会有一些地方与真实定 ...
- @DataProvider Method 参数传递
package roger.testng; import java.lang.reflect.Method; import org.testng.annotations.DataProvider; i ...
- yarn队列提交spark任务权限控制
转载请注明出处:http://www.cnblogs.com/xiaodf/ 1 CapacityScheduler 1.1 模型介绍 1.2 资源分配相关参数 1.3 限制应用程序数目相关参数 1. ...
- r.js 配置文件 build.js 不完整注释
-----------------------------------------------------------------------r.js 配置文件 example.build.js ...
- git 实用命令
git 覆盖本地修改 ,git 放弃本地修改,强制更新 git fetch --all git reset --hard origin/master git fetch 只是下载远程的库的内容,不做任 ...