DOC

Error creating bean with name sessionFactory defined in class path resource applicationContext.xml

By Roberta Pierce,2014-08-13 15:10
11 views 0
Error creating bean with name sessionFactory defined in class path resource applicationContext.xml

    rg.springframework.beans.factory.BeanCreationException: Error creating bean with name

    sessionFactory defined in class path resource applicationContext.xml 异常如下

    javax.servlet.ServletException: Error creating bean with name

    'sessionFactory ' defined in class path resource

    [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError

    org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:523)

    org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)

    org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)

    org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)

    org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414) javax.servlet.http.HttpServlet.service(HttpServlet.java:690) javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

root cause

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory ' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError

    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1175) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:428) org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)

    org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)

    org.springframework.beans.factory.support.AbstractBeanFactory.getBean

(AbstractBeanFactory.java:248)

    org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)

    org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:284) org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)

    org.springframework.context.support.ClassPathXmlApplicationContext. <init> (ClassPathXmlApplicationContext.java:91)

    org.springframework.context.support.ClassPathXmlApplicationContext. <init> (ClassPathXmlApplicationContext.java:75)

    org.springframework.context.support.ClassPathXmlApplicationContext. <init> (ClassPathXmlApplicationContext.java:65)

    com.privilege.action.RolesListAction.execute(RolesListAction.java:52) org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)

    org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)

    org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)

    org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414) javax.servlet.http.HttpServlet.service(HttpServlet.java:690) javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

root cause

java.lang.NoClassDefFoundError

    org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:117)

    org.hibernate.proxy.pojo.cglib.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:43)

    org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:162)

    org.hibernate.tuple.entity.AbstractEntityTuplizer. <init> (AbstractEntityTuplizer.java:135)

    org.hibernate.tuple.entity.PojoEntityTuplizer. <init>

    (PojoEntityTuplizer.java:55)

    org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping. <init> (EntityEntityModeToTuplizerMapping.java:56)

    org.hibernate.tuple.entity.EntityMetamodel. <init>

    (EntityMetamodel.java:295)

    org.hibernate.persister.entity.AbstractEntityPersister. <init> (AbstractEntityPersister.java:434)

    org.hibernate.persister.entity.SingleTableEntityPersister. <init> (SingleTableEntityPersister.java:109)

    org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)

    org.hibernate.impl.SessionFactoryImpl. <init>

    (SessionFactoryImpl.java:226)

    org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)

    org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:825)

    org.springframework.orm.hibernate3.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:751)

    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1202)

    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1172)

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name

    sessionFactory defined in class path resource applicationContext.xml(2)

    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:428) org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)

    org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)

    org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)

    org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)

    org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:284)

    org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)

    org.springframework.context.support.ClassPathXmlApplicationContext. <init> (ClassPathXmlApplicationContext.java:91)

    org.springframework.context.support.ClassPathXmlApplicationContext. <init> (ClassPathXmlApplicationContext.java:75)

    org.springframework.context.support.ClassPathXmlApplicationContext. <init> (ClassPathXmlApplicationContext.java:65)

    com.privilege.action.RolesListAction.execute(RolesListAction.java:52) org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)

    org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)

    org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)

    org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414) javax.servlet.http.HttpServlet.service(HttpServlet.java:690) javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

请高手帮忙解决

    很急啊

------解决方法

    --------------------------------------------------------

    NoClassDefFoundError一般都是缺少jar包的原因?你贴出来的信息看不出来

    缺少什么jar包?你把hibernate里面的jar包全放到lib目录下看看还有错误

    

    ------解决方法

    --------------------------------------------------------

    这个“sessionFactory”bean缺少对应的包吧?你把spring对应的包放到lib

    里面试一试?这个放进去试一试?spring-orm.jar

    ------解决方法

    --------------------------------------------------------

    applicationContext.xml

把这个xml贴出来看看。

    应该是这里面定义的sessionFactory问题。

    或者你看看书如何配置hibernate+spring

    ------解决方法

    --------------------------------------------------------

    Spring Hibernate 共用的一些 jar 文件发生了版本冲突。

    删除 WEB-INF/lib/asm-2.2.3.jar包?试一下。

Report this document

For any questions or suggestions please email
cust-service@docsford.com