首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Exception >

hibernate出现以下异常:net.sf.hibernate.MappingException: Error reading resource,

2014-01-26 
init:build:[javac] Compiling 1 source file to E:\hibernateTest\classes[copy] Copying 2 files to E:\h

init:
 
  build:
  [javac] Compiling 1 source file to E:\hibernateTest\classes
  [copy] Copying 2 files to E:\hibernateTest\classes
 
  run:
  [java] i have come here1111!!
  [java] log4j:WARN No appenders could be found for logger (net.sf.hibernate.
  cfg.Environment).
  [java] log4j:WARN Please initialize the log4j system properly.
  [java] net.sf.hibernate.MappingException: Error reading resource: Customer.
  hbm.xml
  [java] at net.sf.hibernate.cfg.Configuration.addResource(Configuration.
  java:339)
  [java] at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.
  java:1018)
  [java] at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.
  java:974)
  [java] at net.sf.hibernate.cfg.Configuration.configure(Configuration.ja
  va:902)
  [java] at net.sf.hibernate.cfg.Configuration.configure(Configuration.ja
  va:888)
  [java] at Test.main(Unknown Source)
  [java] Caused by: net.sf.hibernate.MappingException: org.dom4j.DocumentExce
  ption: Connection timed out: connect Nested exception: Connection timed out: con
  nect
  [java] at net.sf.hibernate.cfg.Configuration.addInputStream(Configurati
  on.java:296)
  [java] at net.sf.hibernate.cfg.Configuration.addResource(Configuration.
  java:336)
  [java] ... 5 more
  [java] Caused by: org.dom4j.DocumentException: Connection timed out: connec
  t Nested exception: Connection timed out: connect
  [java] at org.dom4j.io.SAXReader.read(SAXReader.java:358)
  [java] at net.sf.hibernate.cfg.Configuration.addInputStream(Configurati
  on.java:286)
  [java] ... 6 more
 
  BUILD SUCCESSFUL
  Total time: 42 seconds
 
 
  是数据库没连上吗?
 
 
 
 

------解决方法--------------------------------------------------------
没法正确读取hbm文件
------解决方法--------------------------------------------------------
<!DOCTYPE hibernate-mapping PUBLIC
  "-//Hibernater/Hibernate Mapping DTD//EN"
  "http://hibernate.sorceforge.net/hibernate-mapping-2.0.dtd">
 
  是因为这句的原因,hibernate在你本地的hibernate包内找不到hibernate-mapping-2.0.dtd
  可能原因hibernate的版本不对,你看一下你的hibernate的
  jar包内是否有hibernate-mapping-X.y.dtd,确保上面跟这个DTD版本是否一致

        

热点排行