0

我正在尝试使用 maven 从http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/tutorial.html的休眠教程构建一个示例,但出现以下错误:

java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:297)
at java.lang.Thread.run(Thread.java:722)
 Caused by: java.lang.ExceptionInInitializerError
at org.hibernate.tutorial.util.HibernateUtil.buildSessionFactory(HibernateUtil.java:18)
at org.hibernate.tutorial.util.HibernateUtil.<clinit>(HibernateUtil.java:8)
at org.hibernate.tutorial.EventManager.createAndStoreEvent(EventManager.java:23)
at org.hibernate.tutorial.EventManager.main(EventManager.java:16)
... 6 more
 Caused by: org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2014)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1926)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1905)
at org.hibernate.tutorial.util.HibernateUtil.buildSessionFactory(HibernateUtil.java:13)
... 9 more
  Caused by: org.dom4j.DocumentException: http://hibernate.sourceforge.net/hibernate-configuration-%0A3.0.dtd Nested exception: http://hibernate.sourceforge.net/hibernate-configuration-%0A3.0.dtd
at org.dom4j.io.SAXReader.read(SAXReader.java:484)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2006)
... 12 more

我在 hibernate.cfg.xml 中将“http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd”替换为“http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd”但它仍然不起作用。

4

1 回答 1

1

我认为您在 URL 中有一个换行符(在行尾返回)。您是否在 String 中注释了%0A(即换行的 acsii 代码).../hibernate-configuration-%0A3.0.dtd

于 2012-05-29T14:21:59.930 回答