1. 程式人生 > >Error creating bean with name 'sessionFactory' defined in file

Error creating bean with name 'sessionFactory' defined in file

問題:

嚴重: Exception sending context initialized event to listener

instance of class

org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error

creating bean with name 'sessionFactory' defined in file [D:/Tomcat

6.0/webapps/Bjtu_SEIE_Website/WEB-INF/classes/applicationContext-

dao.xml]: Instantiation of bean failed; nested exception is

org.springframework.beans.BeanInstantiationException: Could not

instantiate bean class

[org.springframework.orm.hibernate3.LocalSessionFactoryBean]:

Constructor threw exception; nested exception is java.lang.Error:

This version of SLF4J requires log4j version 1.2.12 or later.

 See

org.springframework.beans.factory.support.AbstractAutowireCapableBe

anFactory.instantiateBean

(AbstractAutowireCapableBeanFactory.java:883)
 at

org.springframework.beans.factory.support.AbstractAutowireCapableBe

anFactory.createBeanInstance

(AbstractAutowireCapableBeanFactory.java:839)
 at

org.springframework.beans.factory.support.AbstractAutowireCapableBe

anFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:440)
 at

org.springframework.beans.factory.support.AbstractAutowireCapableBe

anFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
 at java.security.AccessController.doPrivileged(Native

Method)
 at

org.springframework.beans.factory.support.AbstractAutowireCapableBe

anFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
 at

org.springframework.beans.factory.support.AbstractBeanFactory

$1.getObject(AbstractBeanFactory.java:264)
 at

org.springframework.beans.factory.support.DefaultSingletonBeanRegis

try.getSingleton(DefaultSingletonBeanRegistry.java:222)
 at

org.springframework.beans.factory.support.AbstractBeanFactory.doGet

Bean(AbstractBeanFactory.java:261)
 at

org.springframework.beans.factory.support.AbstractBeanFactory.getBe

an(AbstractBeanFactory.java:185)
 at

org.springframework.beans.factory.support.AbstractBeanFactory.getBe

an(AbstractBeanFactory.java:164)
 at

org.springframework.beans.factory.support.DefaultListableBeanFactor

y.preInstantiateSingletons(DefaultListableBeanFactory.java:423)
 at

org.springframework.context.support.AbstractApplicationContext.fini

shBeanFactoryInitialization(AbstractApplicationContext.java:728)
 at

org.springframework.context.support.AbstractApplicationContext.refr

esh(AbstractApplicationContext.java:380)
 at

org.springframework.web.context.ContextLoader.createWebApplicationC

ontext(ContextLoader.java:255)
 at

org.springframework.web.context.ContextLoader.initWebApplicationCon

text(ContextLoader.java:199)
 at

org.springframework.web.context.ContextLoaderListener.contextInitia

lized(ContextLoaderListener.java:45)
 at org.apache.catalina.core.StandardContext.listenerStart

(StandardContext.java:3827)
 at org.apache.catalina.core.StandardContext.start

(StandardContext.java:4336)
 at org.apache.catalina.core.ContainerBase.addChildInternal

(ContainerBase.java:761)
 at org.apache.catalina.core.ContainerBase.addChild

(ContainerBase.java:741)
 at org.apache.catalina.core.StandardHost.addChild

(StandardHost.java:525)
 at org.apache.catalina.startup.HostConfig.deployDirectory

(HostConfig.java:920)
 at

org.apache.catalina.startup.HostConfig.deployDirectories

(HostConfig.java:883)
 at org.apache.catalina.startup.HostConfig.deployApps

(HostConfig.java:492)
 at org.apache.catalina.startup.HostConfig.start

(HostConfig.java:1138)
 at org.apache.catalina.startup.HostConfig.lifecycleEvent

(HostConfig.java:311)
 at

org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent

(LifecycleSupport.java:120)
 at org.apache.catalina.core.ContainerBase.start

(ContainerBase.java:1023)
 at org.apache.catalina.core.StandardHost.start

(StandardHost.java:719)
 at org.apache.catalina.core.ContainerBase.start

(ContainerBase.java:1015)
 at org.apache.catalina.core.StandardEngine.start

(StandardEngine.java:443)
 at org.apache.catalina.core.StandardService.start

(StandardService.java:448)
 at org.apache.catalina.core.StandardServer.start

(StandardServer.java:710)
 at org.apache.catalina.startup.Catalina.start

(Catalina.java:552)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native

Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke

(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke

(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at org.apache.catalina.startup.Bootstrap.start

(Bootstrap.java:288)
 at org.apache.catalina.startup.Bootstrap.main

(Bootstrap.java:413)
Caused by: org.springframework.beans.BeanInstantiationException:

Could not instantiate bean class

[org.springframework.orm.hibernate3.LocalSessionFactoryBean]:

Constructor threw exception; nested exception is java.lang.Error:

This version of SLF4J requires log4j version 1.2.12 or later. See

(BeanUtils.java:115)
 at

org.springframework.beans.factory.support.SimpleInstantiationStrate

gy.instantiate(SimpleInstantiationStrategy.java:61)
 at

org.springframework.beans.factory.support.AbstractAutowireCapableBe

anFactory.instantiateBean

(AbstractAutowireCapableBeanFactory.java:877)
 ... 40 more
Caused by: java.lang.Error: This version of SLF4J requires log4j

version 1.2.12 or later. See also

(StaticLoggerBinder.java:65)
 at org.slf4j.impl.StaticLoggerBinder.<clinit>

(StaticLoggerBinder.java:51)
 at org.slf4j.LoggerFactory.getSingleton

(LoggerFactory.java:228)
 at org.slf4j.LoggerFactory.bind(LoggerFactory.java:120)
 at org.slf4j.LoggerFactory.performInitialization

(LoggerFactory.java:111)
 at org.slf4j.LoggerFactory.getILoggerFactory

(LoggerFactory.java:269)
 at org.slf4j.LoggerFactory.getLogger

(LoggerFactory.java:242)
 at org.slf4j.LoggerFactory.getLogger

(LoggerFactory.java:255)
 at org.hibernate.cfg.Configuration.<clinit>

(Configuration.java:152)
 at java.lang.Class.forName0(Native Method)
 at java.lang.Class.forName(Class.java:169)
 at

org.springframework.orm.hibernate3.LocalSessionFactoryBean.class

$(LocalSessionFactoryBean.java:174)
 at

org.springframework.orm.hibernate3.LocalSessionFactoryBean.<init>

(LocalSessionFactoryBean.java:174)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance0

(Native Method)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance

(NativeConstructorAccessorImpl.java:39)
 at

sun.reflect.DelegatingConstructorAccessorImpl.newInstance

(DelegatingConstructorAccessorImpl.java:27)
 at java.lang.reflect.Constructor.newInstance

(Constructor.java:513)
 at org.springframework.beans.BeanUtils.instantiateClass

(BeanUtils.java:100)
 ... 42 more
Caused by: java.lang.NoSuchFieldError: TRACE
 at org.slf4j.impl.StaticLoggerBinder.<init>

(StaticLoggerBinder.java:63)
 ... 59 more

解決:

替換log4j.jar為高版本