Advertisement
Guest User

Untitled

a guest
Jan 3rd, 2017
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.89 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE hibernate-configuration PUBLIC
  3. "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
  4. "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
  5.  
  6.  
  7. <hibernate-configuration>
  8. <session-factory>
  9.  
  10. <property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
  11. <property name="hibernate.connection.url">jdbc:postgresql://localhost:5432/projet_hibernate</property>
  12. <property name="hibernate.connection.username">postgres</property>
  13. <property name="hibernate.connection.password">password</property>
  14. <property name="connection_pool_size">1</property>
  15. <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
  16. <property name="current_session_context_class">thread</property>
  17.  
  18. <!-- Disable the second-level cache -->
  19. <property name="cache.provider_class">org.hibernate.cache.internal.NoCacheProvider</property>
  20.  
  21. <property name="show_sql">true</property>
  22. <property name="hbm2ddl.auto">create</property>
  23.  
  24. <mapping resource="bean/Lecteurs.hbm.xml"/>
  25. </session-factory>
  26.  
  27. package util;
  28. import org.hibernate.SessionFactory;
  29. import org.hibernate.cfg.AnnotationConfiguration;
  30. //import org.hibernate.cfg.Configuration;
  31.  
  32. public class HibernateUtil {
  33.  
  34. public static final SessionFactory sessionFactory = buildSessionFactory();
  35.  
  36. private static SessionFactory buildSessionFactory() {
  37. try {
  38. // Create the SessionFactory from hibernate.cfg.xml
  39. return new AnnotationConfiguration().configure().buildSessionFactory();
  40.  
  41. }
  42. catch (Throwable ex) {
  43. // Make sure you log the exception, as it might be swallowed
  44. System.err.println("Initial SessionFactory creation failed." + ex);
  45. throw new ExceptionInInitializerError(ex);
  46. }
  47. }
  48.  
  49. public static SessionFactory getSessionFactory(){
  50. return sessionFactory;
  51.  
  52. }
  53.  
  54. public static void shutdown() {
  55. // Close caches and connection pools
  56. getSessionFactory().close();
  57. }
  58. }
  59.  
  60. Initial SessionFactory creation failed.java.lang.NoClassDefFoundError: org/hibernate/annotations/common/reflection/ReflectionManager
  61. Exception in thread "main" java.lang.ExceptionInInitializerError
  62. at util.HibernateUtil.buildSessionFactory(HibernateUtil.java:20)
  63. at util.HibernateUtil.<clinit>(HibernateUtil.java:9)
  64. at manager.LecteursManager.ajouterLecteur(LecteursManager.java:14)
  65. at test.Test_Main.main(Test_Main.java:18)
  66. Caused by: java.lang.NoClassDefFoundError: org/hibernate/annotations/common/reflection/ReflectionManager
  67. at util.HibernateUtil.buildSessionFactory(HibernateUtil.java:14)
  68. ... 3 more
  69. Caused by: java.lang.ClassNotFoundException: org.hibernate.annotations.common.reflection.ReflectionManager
  70. at java.net.URLClassLoader.findClass(Unknown Source)
  71. at java.lang.ClassLoader.loadClass(Unknown Source)
  72. at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
  73. at java.lang.ClassLoader.loadClass(Unknown Source)
  74. ... 4 more
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement