坑爹的Hibernate 映射文件错误提示org.xml.sax.SAXParseException
今天整整一个上午都在和hibernate做斗争,早上一来,继续昨天的项目开发,发现spring项目不能启动,从错误中看是hibernate错误,多半是hibernate配置有错误,关键是错误提示中显示“com.mdnet.travel.core.dao.ValidCodeDAOImpl”不能注入,经过仔细查看未见异常,而且这个文件好久没有改过了。没办法把hibernate的配置改成如下配置:
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"
p:dataSource-ref="dataSource">
<property name="mappingLocations">
<list>
<value>classpath:/com/mdnet/travel/model/mapping/Article.hbm.xml
</value>
<value>classpath:/com/mdnet/travel/model/mapping/Customer.hbm.xml
</value>
<value>classpath:/com/mdnet/travel/model/mapping/key_define.hbm.xml
</value>
<value>classpath:/com/mdnet/travel/model/mapping/Media.hbm.xml
</value>
<value>classpath:/com/mdnet/travel/model/mapping/menu_define.hbm.xml
</value>
<value>classpath:/com/mdnet/travel/model/mapping/Traveler.hbm.xml
</value>
<value>classpath:/com/mdnet/travel/model/mapping/ReqMessage.hbm.xml
</value>
<value>classpath:/com/mdnet/travel/model/mapping/Special.hbm.xml
</value>
<value>classpath:/com/mdnet/travel/model/mapping/WeixinAccount.hbm.xml
</value>
<value>classpath:/com/mdnet/travel/model/mapping/ValidateCode.hbm.xml
</value>
<value>classpath:/com/mdnet/travel/model/mapping/WeixinOrder.hbm.xml
</value>
</list> </property> <property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>
</bean>
首先去掉 <value>classpath:/com/mdnet/travel/model/mapping/ValidateCode.hbm.xml</value>,启动项目发现故障依旧,于是逐个屏蔽hibernate配置文件,
当屏蔽<value>classpath:/com/mdnet/travel/model/mapping/WeixinOrder.hbm.xml</value>这个时,发现项目启动成功,这才想起来,前一天是改动了这个文件,因为有急事没有改完就关机了(以后可是不能这样啦,自己挖坑,自己跳)。
坑爹的hibernate从来不说那个配置文件有错误,害得错误到处找。
下面是详细的报错信息,以后大家遇到类似错注意所有的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 'accountController': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.mdnet.travel.core.service.impl.TravelerServiceImpl': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.mdnet.travel.core.dao.ValidCodeDAOImpl': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [weixin_beans.xml]: Invocation of init method failed; nested exception is org.hibernate.InvalidMappingException: Unable to read XML
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:306)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1146)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:628)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.mdnet.travel.core.service.impl.TravelerServiceImpl': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.mdnet.travel.core.dao.ValidCodeDAOImpl': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [weixin_beans.xml]: Invocation of init method failed; nested exception is org.hibernate.InvalidMappingException: Unable to read XML
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:306)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1146)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:198)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:444)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:418)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:546)
at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:150)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:303)
... 23 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.mdnet.travel.core.dao.ValidCodeDAOImpl': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [weixin_beans.xml]: Invocation of init method failed; nested exception is org.hibernate.InvalidMappingException: Unable to read XML
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:306)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1146)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:198)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:444)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:418)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:546)
at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:150)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:303)
... 34 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [weixin_beans.xml]: Invocation of init method failed; nested exception is org.hibernate.InvalidMappingException: Unable to read XML
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1512)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:198)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:444)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:418)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:546)
at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:159)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:303)
... 45 more
Caused by: org.hibernate.InvalidMappingException: Unable to read XML
at org.hibernate.util.xml.MappingReader.readMappingDocument(MappingReader.java:101)
at org.hibernate.cfg.Configuration.add(Configuration.java:510)
at org.hibernate.cfg.Configuration.add(Configuration.java:506)
at org.hibernate.cfg.Configuration.add(Configuration.java:686)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:726)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:687)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:188)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1571)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1509)
... 57 more
Caused by: org.xml.sax.SAXParseException; lineNumber: 143; columnNumber: 10; 元素类型为 "class" 的内容必须匹配 "(meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,(id|composite-id),discriminator?,natural-id?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array)*,((join*,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*,fetch-profile*,resultset*,(query|sql-query)*)"。
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:437)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:368)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:325)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleEndElement(XMLDTDValidator.java:1994)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.endElement(XMLDTDValidator.java:879)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1741)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2898)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:607)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:116)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:488)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:835)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:123)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1210)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:568)
at org.dom4j.io.SAXReader.read(SAXReader.java:465)
at org.hibernate.util.xml.MappingReader.readMappingDocument(MappingReader.java:75)
... 65 more
坑爹的Hibernate 映射文件错误提示org.xml.sax.SAXParseException的更多相关文章
- Spring集成Hibernate映射文件的4种方式
概要: 在Spring的applicationContext.xml中集成Hibernate映射文件,通常是在<sessionFactory>这个Bean实例中进行的,若配置的映射文件较少 ...
- 生成 hibernate 映射文件和实体类
创建web工程,使用Hibernate的时候,在工程里一个一个创建实体类太麻烦,浪费时间,现在教大家如何用MyEclipse自动生成Hibernate映射文件及实体类 方法/步骤 创建数据库,创建 ...
- Hibernate映射文件如何配置触发器
Hibernate映射文件之触发器生成(generated属性.database-object元素) (2013-02-27 12:28:49) 转载▼ 标签: it 分类: JAVA学习笔记 这里分 ...
- Halcon的应用程序 打开后 弹出没有帮助文件错误提示
问题: Halcon的应用程序 打开后 弹出没有帮助文件错误提示 解决方法: 建立(C:\ProgramFiles\MVTec\halcon)目录,将halcon安装目录下的help文件夹复制过来即可 ...
- Java学习笔记(十三)——通过Netbeans开发环境生成oracle数据库中表的对应hibernate映射文件
[前面的话] 身体慢慢已经快好了,感觉真好,哈哈. 这篇文章要通过Hibernate对数据库进行操作,而Netbeans可以直接通过数据库逆向生成对应的映射文件.基础文章,选择性阅读. [步骤] 1. ...
- spring配置hibernate映射文件-------通配符
<!-- 这里一定要注意是使用spring的mappingLocations属性进行通配的 --> <property name="mappingLocation ...
- hibernate映射文件set key one-to-many
转自:https://www.linuxidc.com/Linux/2013-11/92228.htm 1 hibernate映射文件set key one-to-many的配置. POJOs如下: ...
- LocalSessionFactoryBean有几个属性查找hibernate映射文件
LocalSessionFactoryBean有几个属性查找hibernate映射文件: mappingResources.mappingLocations.mappingDirectoryLocat ...
- Hibernate映射文件详解(News***.hbm.xml)二
转自 http://blog.csdn.net/a9529lty/article/details/6454924 一.hibernate映射文件的作用: Hibernate映射文件是Hibernate ...
随机推荐
- mongoDB - 插入数据
db.use.js /** * 使用前:先安装node环境.express.mongodb. * * 1.1 安装Node * 1.2 npm i -D express mongodb &&a ...
- DBCC MEMORYSTATUS
内存管理器 输出的第一节是内存管理器.此部分将显示 SQL Server 的总内存消耗. Memory Manager KB ------------------------------ ------ ...
- Linux Java开发环境
一.旧版本JDK卸载 1.卸载系统自带JDK版本 #rpm -qa|grep gcj 查看到如下信息,如图所示: 进行卸载默认安装JDK: #rpm -e --nodeps java-1.4.2- ...
- Linux——Django 开发环境部署(二)python版本控制器pyenv
python版本控制器pyenv 之前的 那篇是说明了django环境的site package完全独立出来了,但是使用的python解释器还是系统的,为了继续独立出来,甚至是达到ruby的rvm的自 ...
- tail -f 不断刷新
查看log tail -f 会将其不断刷新显示
- HttpClient简介
栏目:Web开发 作者:admin 日期:2015-05-02 评论:0 点击: 204 次 虽然在JDK的java net包中已经提供了访问 HTTP 协议的基本功能,但是对于大部分应用程序来说 ...
- 基于JWT的Token开发案例
代码地址如下:http://www.demodashi.com/demo/12531.html 0.准备工作 0-1运行环境 jdk1.8 maven 一个能支持以上两者的代码编辑器,作者使用的是ID ...
- 会话管理之session技术
上一节我们总结了cookie技术,这节主要总结一下session技术. 1. session对象 在web开发中,服务器可以为每个用户浏览器创建一个会话对象(session对象),注意:一个浏览器独占 ...
- Android下 布局加边框 指定背景色 半透明
背景设置为自定义的shape文件: <!-- <?xml version="1.0" encoding="utf-8"?><shape ...
- maven依赖json-lib失败
© 版权声明:本文为博主原创文章,转载请注明出处 项目中需要使用到JSONArray,因此到将json-lib的依赖加入pom.xml中,但是一直下载失败 <dependency> < ...