Hibernate连接SQLserver出错,SEVERE: Error parsing XML: XML InputStream(2) The markup in the document preceding the root element

leafxx 2005-04-25 04:53:28
以下是我的eclipse的出错信息

INFO: Mapping resource: com/jeffrey/messagelove/User.hbm.xml
Apr 25, 2005 4:49:17 PM net.sf.hibernate.util.XMLHelper$ErrorLogger error
SEVERE: Error parsing XML: XML InputStream(2) The markup in the document preceding the root element must be well-formed.
Apr 25, 2005 4:49:17 PM net.sf.hibernate.cfg.Configuration addInputStream
SEVERE: Could not configure datastore from input stream
org.dom4j.DocumentException: Error on line 2 of document : The markup in the document preceding the root element must be well-formed. Nested exception: The markup in the document preceding the root element must be well-formed.
at org.dom4j.io.SAXReader.read(SAXReader.java:355)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:287)
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:337)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:1027)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:983)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:911)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:897)
at com.jeffrey.messagelove.test.HibernateTest.setUp(HibernateTest.java:29)
at junit.framework.TestCase.runBare(TestCase.java:125)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
Nested exception:

不明白什么意思!!!

以下附上相应配置文件:
[hibernate.cfg.xml]

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">

<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.url">
jdbc:jtds:sqlserver://localhost:1433/MessageLove
</property>

<property name="hibernate.connection.driver_class">
net.sourceforge.jtds.jdbc.Driver
</property>

<property name="hibernate.connection.username">
sa
</property>

<property name="hibernate.connection.password">
123456
</property>

<property name="dialect">
net.sf.hibernate.dialect.SQLServerDialect
</property>

<property name="hibernate.show_sql">
True
</property>

<property name="hibernate.use_outer_join">
True
</property>

<property name="hibernate.transaction.factory_class">
net.sf.hibernate.transaction.JDBCTransactionFactory
</property>

<mapping resource="com/jeffrey/messagelove/User.hbm.xml"/>

</session-factory>
</hibernate-configuration>


[User.hbm.xml]
<?xml version="1.0" ?>
<! DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate//Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
<class name="com.jeffrey.messagelove.User" table="t_user">

<id name="userName" type="java.lang.String>
<column name="t_username" sql-type="varchar(16)" not-null="true"/>
<generator class="assigned"/>
</id>

<property name="password" type="java.lang.String">
<column name="t_password" sql-type="varchar(16)" not-null="true"/>
</property>

<property name="nickname" type="java.lang.String">
<column name="t_nickname" sql-type="varchar(16)"/>
</property>

</class>
</hibernate-mapping>
...全文
471 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
MARS.nEIL 2005-04-25
  • 打赏
  • 举报
回复
The markup in the document preceding the root element must be well-formed.
根前面的标记有问题

67,515

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧