1. ホーム
  2. Hibernate

org.xml.sax.SAXParseException: ルート要素に先行する文書内のマークアップは,十分にfoでなければならない。

2022-02-17 04:14:05
Exception in thread "main" java.lang.RuntimeException: Error occurred. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: The markup in the document preceding the root element must be well-formed.
	at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConfigParser.java:89)
	at com.ibatis.sqlmap.client.SqlMapClientBuilder.buildSqlMapClient(SqlMapClientBuilder.java:63)
	at com.fgh.Test.main(Test.java:22)
Caused by: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: The markup in the document SAXParseException: The markup in the document preceding the root element must be well-formed.
	SAXParseException: The markup in the document preceding the root element must be well-formed. at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:53)
	at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConfigParser.java:86)
	... 2 more
Caused by: org.xml.sax.SAXParseException: The markup in the document preceding the root element must be well-formed.
	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:236)
	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:215)
	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:386)
	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:316)
	at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1438)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDispatcher.dispatch(XMLDocumentScannerImpl.java:815)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
	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:148)
	at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:250)
	at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:292)
	at com.ibatis.common.xml.NodeletParser.createDocument(NodeletParser.java:157)
	at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:50)
	... 3 more









エラーの理由

設定ファイルに <?xml version="1.0" encoding="UTF-8"? >.が含まれている。
<! DOCTYPE sqlMapConfig    
PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN" 
"http://www.ibatis.com/dtd/sql-map-config-2.dtd" >

<! DOCTYPE 間に複数のスペースがある