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

org.xml.sax.SAXParseException: Document is invalid: no grammar found

2014-01-26 
我的Customer.hbm.xml文件如下:?xml version1.0?hibernate-mappingclass nameCustomer tableC

  我的Customer.hbm.xml文件如下:
  <?xml version="1.0"?>
  <hibernate-mapping>
  <class name="Customer" table="CUSTOMER">
  <id name="id" column="CID">
  <gernerate class="increment"/>
  </id>
  <property name="username" column="USERNAME"/>
  <property name="password" column="PASSWOED"/>
  </class>
  </hibernate-mapping>
  报的错:
  test hibernate!!
  log4j:WARN No appenders could be found for logger (net.sf.hibernate.cfg.Environment).
  log4j:WARN Please initialize the log4j system properly.
  net.sf.hibernate.MappingException: Error reading resource: Customer.hbm.xml
  at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:318)
  at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:976)
  at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:928)
  at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:856)
  at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:842)
  at Test.main(Test.java:17)
  Caused by: net.sf.hibernate.MappingException: invalid mapping
  at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:284)
  at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:315)
  ... 5 more
  Caused by: org.xml.sax.SAXParseException: Document is invalid: no grammar found.
  at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
  at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
  at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
  at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
  at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
  at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown Source)
  at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
  at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
  at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
  at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
  at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
  at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
  at org.dom4j.io.SAXReader.read(SAXReader.java:339)
  at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:283)
  ... 6 more   
    
  这是什么问题。   

------解决方法--------------------------------------------------------
你是不是用ultraedit编辑过他了, 看看头上是不是多了几个字节? 用二进制看看.
  如果是的话把那几个字节删除 
 

        

热点排行