出错了!请大家帮下忙...

wgzh159 发布于 2011/03/03 11:09
阅读 1K+
收藏 0

启动项目时出错了,请大家帮下忙...

Initial SessionFactory creation failed.java.lang.NoClassDefFoundError: org/apache/log4j/LogManager
Exception in thread "main" java.lang.ExceptionInInitializerError
    at cn.hibernate.util.HibernateUtils.buildSessionFactory(HibernateUtils.java:17)
    at cn.hibernate.util.HibernateUtils.<clinit>(HibernateUtils.java:8)
    at cn.hibernate.main.EventManager.createAndStoreEvent(EventManager.java:22)
    at cn.hibernate.main.EventManager.main(EventManager.java:15)
Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/LogManager
    at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:73)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:243)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:255)
    at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:165)
    at cn.hibernate.util.HibernateUtils.buildSessionFactory(HibernateUtils.java:13)
    ... 3 more
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.LogManager
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    ... 8 more

 

项目中引入的包:

log4j.properties文件

### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

### direct messages to file hibernate.log ###
#log4j.appender.file=org.apache.log4j.FileAppender
#log4j.appender.file.File=hibernate.log
#log4j.appender.file.layout=org.apache.log4j.PatternLayout
#log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

### set log levels - for more verbose logging change 'info' to 'debug' ###

log4j.rootLogger=warn, stdout

#log4j.logger.org.hibernate=info
log4j.logger.org.hibernate=debug

### log HQL query parser activity
#log4j.logger.org.hibernate.hql.ast.AST=debug

### log just the SQL
#log4j.logger.org.hibernate.SQL=debug

### log JDBC bind parameters ###
log4j.logger.org.hibernate.type=info
#log4j.logger.org.hibernate.type=debug

### log schema export/update ###
log4j.logger.org.hibernate.tool.hbm2ddl=debug

### log HQL parse trees
#log4j.logger.org.hibernate.hql=debug

### log cache activity ###
#log4j.logger.org.hibernate.cache=debug

### log transaction activity
#log4j.logger.org.hibernate.transaction=debug

### log JDBC resource acquisition
#log4j.logger.org.hibernate.jdbc=debug

### enable the following line if you want to track down connection ###
### leakages when using DriverManagerConnectionProvider ###
#log4j.logger.org.hibernate.connection.DriverManagerConnectionProvider=trace

 

加载中
0
红薯
红薯

缺少 log4j 的 jar 包

0
徐小路
徐小路

引用来自#2楼“红薯”的帖子

缺少 log4j 的 jar 包

老大,真快!

0
wgzh159
wgzh159

谢谢了,我以为上面的slf4j-log4j12-1.5.8.jar就是那个包

返回顶部
顶部