问题描述
严重:Exceptionsendingcontextinitializedeventtolistenerinstanceofclassorg.springframework.web.context.ContextLoaderListenerorg.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'sessionFactory'definedinclasspathresource[applicationContext.xml]:Invocationofinitmethodfailed;nestedexceptionisorg.hibernate.InvalidMappingException:Couldnotparsemappingdocumentfrominputstreamatorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)atjava.security.AccessController.doPrivileged(NativeMethod)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)atorg.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)atorg.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)atorg.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)atorg.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423)atorg.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)atorg.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)atorg.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)atorg.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)atorg.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)atorg.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3827)atorg.apache.catalina.core.StandardContext.start(StandardContext.java:4334)atorg.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)atorg.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)atorg.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)atorg.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)atorg.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)atorg.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)atorg.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)atorg.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)atorg.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)atorg.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)atorg.apache.catalina.core.StandardHost.start(StandardHost.java:719)atorg.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)atorg.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)atorg.apache.catalina.core.StandardService.start(StandardService.java:516)atorg.apache.catalina.core.StandardServer.start(StandardServer.java:710)atorg.apache.catalina.startup.Catalina.start(Catalina.java:566)atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)atjava.lang.reflect.Method.invoke(Method.java:606)atorg.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)atorg.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)Causedby:org.hibernate.InvalidMappingException:Couldnotparsemappingdocumentfrominputstreamatorg.hibernate.cfg.Configuration.addInputStream(Configuration.java:541)atorg.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:631)atorg.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)...39moreCausedby:org.dom4j.DocumentException:www.hibernate.orgNestedexception:www.hibernate.orgatorg.dom4j.io.SAXReader.read(SAXReader.java:484)atorg.hibernate.cfg.Configuration.addInputStream(Configuration.java:532)...43more十二月12,201411:25:10上午org.apache.catalina.core.StandardContextstart严重:ErrorlistenerStart十二月12,201411:25:10上午org.apache.catalina.core.StandardContextstart严重:Context[/Card_SSH]startupfailedduetopreviouserrors十二月12,201411:25:10上午org.apache.catalina.core.ApplicationContextlog信息:ClosingSpringrootWebApplicationContext十二月12,201411:25:10上午org.apache.coyote.http11.Http11Protocolstart信息:StartingCoyoteHTTP/1.1onhttp-8080十二月12,201411:25:10上午org.apache.jk.common.ChannelSocketinit信息:JK:ajp13listeningon/0.0.0.0:8009十二月12,201411:25:10上午org.apache.jk.server.JkMainstart信息:JkrunningID=0time=0/49config=null十二月12,201411:25:10上午org.apache.catalina.startup.Catalinastart
解决方案
解决方案二:
User.hbm.xml<?xmlversion="1.0"encoding="utf-8"?><!DOCTYPEhibernate-mappingPUBLIC"-//Hibernate/HibernateMappingDTD3.0//EN""http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"><!--MappingfileautogeneratedbyMyEclipsePersistenceTools--><hibernate-mappingpackage="bean"><classname="User"><idname="id"><generatorclass="native"/></id><propertyname="name"/><propertyname="password"/></class></hibernate-mapping>
Card.hbm.xml<?xmlversion="1.0"encoding="utf-8"?><!DOCTYPEhibernate-mappingPUBLIC"-//Hibernate/HibernateMappingDTD3.0//EN""http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"><!--MappingfileautogeneratedbyMyEclipsePersistenceTools--><hibernate-mappingpackage="bean"><classname="Card"><idname="id"><generatorclass="native"/></id><propertyname="name"/><propertyname="phone"/><propertyname="flag"/><many-to-onename="user"column="user_id"cascade="save-update"></many-to-one></class></hibernate-mapping>
解决方案三:
.hbm这些都是自动生成的,一般不会有什么错,我也在SSH整合中出现过这样的问题,可能的原因是你原来项目的错误影响了你现在的项目,你可以尝试清楚workspace,然后弄新的项目,嘻嘻
解决方案四:
springhibernate包冲突,或者缺包。你百度一下spring+hibernate需要的包,最好用MyEclipse直接搭建框架,这样不会缺包或者重复。
解决方案五:
错误应该是Card.hbm.xml未设置字段的type
解决方案六:
类似这种缺少了class<many-to-onename="gradeClass"column="gradeClassId"class="com.supben.pojo.GradeClass"/>
解决方案七:
感谢诸位,中午有事出去了,没有回复很抱歉,问题已经解决了,换了个Tomcat服务器。。
解决方案八:
现在又出了新问题--,搞不明白咋回事严重:Exceptionsendingcontextinitializedeventtolistenerinstanceofclassorg.springframework.web.context.ContextLoaderListenerorg.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'userAction'definedinclasspathresource[applicationContext.xml]:Initializationofbeanfailed;nestedexceptionisorg.springframework.beans.TypeMismatchException:Failedtoconvertpropertyvalueoftype[com.sun.proxy.$Proxy7implementingdaoInterface.UserInterface,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised]torequiredtype[dao.UserDAO]forproperty'userdao';nestedexceptionisjava.lang.IllegalArgumentException:Cannotconvertvalueoftype[com.sun.proxy.$Proxy7implementingdaoInterface.UserInterface,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised]torequiredtype[dao.UserDAO]forproperty'userdao':nomatchingeditorsorconversionstrategyfoundatorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:480)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)atjava.security.AccessController.doPrivileged(NativeMethod)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)atorg.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)atorg.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)atorg.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)atorg.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)atorg.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)atorg.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)atorg.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)atorg.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)atorg.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)atorg.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4791)atorg.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285)atorg.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)atorg.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)atorg.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)atorg.apache.catalina.core.StandardHost.addChild(StandardHost.java:618)atorg.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1100)atorg.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1618)atjava.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)atjava.util.concurrent.FutureTask.run(FutureTask.java:262)atjava.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)atjava.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)atjava.lang.Thread.run(Thread.java:744)Causedby:org.springframework.beans.TypeMismatchException:Failedtoconvertpropertyvalueoftype[com.sun.proxy.$Proxy7implementingdaoInterface.UserInterface,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised]torequiredtype[dao.UserDAO]forproperty'userdao';nestedexceptionisjava.lang.IllegalArgumentException:Cannotconvertvalueoftype[com.sun.proxy.$Proxy7implementingdaoInterface.UserInterface,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised]torequiredtype[dao.UserDAO]forproperty'userdao':nomatchingeditorsorconversionstrategyfoundatorg.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:391)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1289)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1250)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)...27moreCausedby:java.lang.IllegalArgumentException:Cannotconvertvalueoftype[com.sun.proxy.$Proxy7implementingdaoInterface.UserInterface,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised]torequiredtype[dao.UserDAO]forproperty'userdao':nomatchingeditorsorconversionstrategyfoundatorg.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:231)atorg.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:138)atorg.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:386)...31more