Guest User

Untitled

a guest
Dec 12th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.40 KB | None | 0 0
  1. org.hibernate.HibernateException: Could not parse configuration: hibernate.cfg.xml
  2.  
  3. <?xml version='1.0' encoding='utf-8'?>
  4. <!DOCTYPE hibernate-configuration PUBLIC
  5. "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
  6. "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
  7.  
  8. <hibernate-configuration>
  9. <session-factory>
  10.  
  11. <!-- Database connection settings -->
  12. <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
  13. <property name="connection.url">jdbc:mysql://localhost:3306/test-db</property>
  14. <property name="connection.username">user</property>
  15. <property name="connection.password">password</property>
  16.  
  17. <!-- SQL dialect -->
  18. <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
  19.  
  20. <!-- Echo all executed SQL to stdout -->
  21. <property name="show_sql">true</property>
  22.  
  23. <!-- Use XML-based mapping metadata -->
  24. <!-- <mapping resource="domain/Message.hbm.xml"/> -->
  25.  
  26. <!-- Use Annotation-based mapping metadata -->
  27. <mapping class="entity.Message"/>
  28.  
  29. </session-factory>
  30. </hibernate-configuration>
  31.  
  32. Successfully started process 'command 'C:Program FilesJavajdk1.8.0_65binjava.exe''
  33. Dec 16, 2015 12:01:20 AM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
  34. INFO: HCANN000001: Hibernate Commons Annotations {4.0.4.Final}
  35. Dec 16, 2015 12:01:20 AM org.hibernate.Version logVersion
  36. INFO: HHH000412: Hibernate Core {4.3.5.Final}
  37. Dec 16, 2015 12:01:21 AM org.hibernate.cfg.Environment <clinit>
  38. INFO: HHH000206: hibernate.properties not found
  39. Dec 16, 2015 12:01:21 AM org.hibernate.cfg.Environment buildBytecodeProvider
  40. INFO: HHH000021: Bytecode provider name : javassist
  41. Dec 16, 2015 12:01:21 AM org.hibernate.cfg.Configuration configure
  42. INFO: HHH000043: Configuring from resource: hibernate.cfg.xml
  43. Dec 16, 2015 12:01:21 AM org.hibernate.cfg.Configuration getConfigurationInputStream
  44. INFO: HHH000040: Configuration resource: hibernate.cfg.xml
  45. Initial SessionFactory creation failed.org.hibernate.HibernateException: Could not parse configuration: hibernate.cfg.xml
  46. Exception in thread "main" java.lang.ExceptionInInitializerError
  47. at util.HibernateUtil.buildSessionFactory(HibernateUtil.java:25)
  48. at util.HibernateUtil.<clinit>(HibernateUtil.java:12)
  49. at client.HelloWorldClient.main(HelloWorldClient.java:13)
  50. Caused by: org.hibernate.HibernateException: Could not parse configuration: hibernate.cfg.xml
  51. at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2163)
  52. at org.hibernate.cfg.Configuration.configure(Configuration.java:2075)
  53. at util.HibernateUtil.buildSessionFactory(HibernateUtil.java:18)
  54. ... 2 more
  55. Caused by: org.dom4j.DocumentException: Error on line 2 of document : The processing instruction target matching "[xX][mM][lL]" is not allowed. Nested exception: The processing instruction target matching "[xX][mM][lL]" is not allowed.
  56. at org.dom4j.io.SAXReader.read(SAXReader.java:482)
  57. at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2155)
  58. ... 4 more
  59. :run FAILED
  60. :run (Thread[Daemon worker Thread 15,5,main]) completed. Took 0.617 secs.
  61.  
  62. FAILURE: Build failed with an exception.
  63.  
  64. * What went wrong:
  65. Execution failed for task ':run'.
  66. > Process 'command 'C:Program FilesJavajdk1.8.0_65binjava.exe'' finished with non-zero exit value 1
  67.  
  68. * Try:
  69. Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.
  70.  
  71. BUILD FAILED
  72.  
  73. package client;
  74.  
  75. import org.hibernate.Session;
  76.  
  77. import util.HibernateUtil;
  78. import entity.Message;
  79.  
  80.  
  81. public class HelloWorldClient {
  82. public static void main(String[] args) {
  83.  
  84. Session session = HibernateUtil.getSessionFactory().openSession();
  85. session.beginTransaction();
  86.  
  87. Message message = new Message( "Hello World with Hibernate & JPA Annotations" );
  88.  
  89. session.save(message);
  90.  
  91. session.getTransaction().commit();
  92. session.close();
  93.  
  94. }
  95. }
  96.  
  97. <?xml version="1.0" encoding="UTF-8"?>
  98. <!DOCTYPE hibernate-configuration PUBLIC
  99. "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
  100. "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
  101. <hibernate-configuration>
  102. <session-factory>
  103. <property name="hibernate.connection.driver_class"> com.mysql.jdbc.Driver </property>
  104. <property name="hibernate.connection.url"> jdbc:mysql://localhost:3306/hibernatex </property>
  105. <property name="hibernate.connection.username"> root </property>
  106. <property name="hibernate.connection.password"> root </property>
  107. <property name="hibernate.dialect"> org.hibernate.dialect.MySQLDialect </property>
  108. <mapping resource="com/ora/hibernate/examples/Employee.hbm.xml"
  109. package="com.ora.hibernate.examples" />
  110. </session-factory>
  111. </hibernate-configuration>
  112.  
  113. <?xml version="1.0" encoding="utf-8"?>
  114. <!DOCTYPE hibernate-configuration PUBLIC
  115. "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
  116. "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
  117.  
  118. <?xml version="1.0" encoding="utf-8"?>
  119. <!DOCTYPE hibernate-configuration SYSTEM
  120. "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
  121.  
  122. <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "C:Downloadshibernate-mapping-3.0.dtd"> <hibernate-configuration>
Add Comment
Please, Sign In to add comment