我正在尝试使用maven从http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/tutorial.html的hibernate教程构建一个示例,我收到以下错误:
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
我将“http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd”替换为 我的hibernate.cfg.xml中的“http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd”但它仍然不起作用。
答案 0 :(得分:1)
我认为您在网址中有换行符(在行尾返回)。您是否在字符串%0A
中注释了.../hibernate-configuration-%0A3.0.dtd
(换行的acsii代码)?