spring整合hibernate出现的异常

严重: 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 class path resource [applicationContext.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.NoClassDefFoundError

Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError

Caused by: java.lang.NoClassDefFoundError
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.ClassNotFoundException: org.hibernate.cfg.Configuration

这个信息出现的原因有以下可能:
1.配置文件错误(不在多说,自己检查)
2.没有完全整合spring与hibernate框架,在项目中使用了hibernate的ORM映射与hibernate.cfg.xml连接数据库的配置文件如此需要加入hibernate源码jar包。如果不需要hibernate的话,则要将配置文件信息全写在applicationContext.xml文件中或相关文件中。运行后还是报错,则是asm的jar包冲突

你可能感兴趣的:(JAVA异常)