Advertisement
Guest User

Untitled

a guest
Jan 14th, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.81 KB | None | 0 0
  1. "Failed to create sessionFactory object.org.hibernate.HibernateException: could not init listeners"
  2.  
  3. - Hibernate Commons Annotations 3.2.0.Final
  4. - Hibernate 3.6.10.Final
  5. - hibernate.properties not found
  6. - Bytecode provider name : javassist
  7. - using JDK 1.4 java.sql.Timestamp handling
  8. - configuring from resource: extalshibernatehibernate.cfg.xml
  9. - Configuration resource: extalshibernatehibernate.cfg.xml
  10. - Reading mappings from resource : extalshibernatemappingsDocument.hbm.xml
  11. - Configured SessionFactory: null
  12. - Mapping class: ext.als.xcg.mrp.traceability.beans.Document -> DOCUMENT
  13. - Using Hibernate built-in connection pool (not for production use!)
  14. - Hibernate connection pool size: 1
  15. - autocommit mode: false
  16. - using driver: oracle.jdbc.OracleDriver at URL: jdbc:oracle:thin:@localhost:1521:wind
  17. - connection properties: {user=mrp, password=****}
  18. - Using dialect: org.hibernate.dialect.Oracle9iDialect
  19. - Could not obtain connection metadata
  20. - Using default transaction strategy (direct JDBC transactions)
  21. - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
  22. - Automatic flush during beforeCompletion(): disabled
  23. - Automatic session close at end of transaction: disabled
  24. - JDBC batch size: 15
  25. - JDBC batch updates for versioned data: disabled
  26. - Scrollable result sets: enabled
  27. - JDBC3 getGeneratedKeys(): disabled
  28. - Connection release mode: auto
  29. - Default batch fetch size: 1
  30. - Generate SQL with comments: disabled
  31. - Order SQL updates by primary key: disabled
  32. - Order SQL inserts for batching: disabled
  33. - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
  34. - Using ASTQueryTranslatorFactory
  35. - Query language substitutions: {}
  36. - JPA-QL strict compliance: disabled
  37. - Second-level cache: enabled
  38. - Query cache: disabled
  39. - Cache region factory : org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge
  40. - Cache provider: org.hibernate.cache.NoCacheProvider
  41. - Optimize cache for minimal puts: disabled
  42. - Structured second-level cache entries: disabled
  43. - Echoing all SQL to stdout
  44. - Statistics: disabled
  45. - Deleted entity synthetic identifier rollback: disabled
  46. - Default entity-mode: pojo
  47. - Named query checking : enabled
  48. - Check Nullability in Core (should be disabled when Bean Validation is on): enabled
  49. Failed to create sessionFactory object.org.hibernate.HibernateException: could not init listeners
  50. Exception in thread "main" java.lang.ExceptionInInitializerError
  51. at ext.als.xcg.mrp.traceability.manager.DocumentManager.main(DocumentManager.java:26)
  52. Caused by: org.hibernate.HibernateException: could not init listeners
  53. at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:205)
  54. at org.hibernate.cfg.Configuration.getInitializedEventListeners(Configuration.java:2010)
  55. at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1872)
  56. at ext.als.xcg.mrp.traceability.manager.DocumentManager.main(DocumentManager.java:21)
  57. Caused by: java.lang.ClassCastException: org.hibernate.cfg.Configuration
  58. at org.hibernate.search.event.FullTextIndexEventListener.initialize(FullTextIndexEventListener.java:82)
  59. at org.hibernate.event.EventListeners$1.processListener(EventListeners.java:198)
  60. at org.hibernate.event.EventListeners.processListeners(EventListeners.java:181)
  61. at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:194)
  62. ... 3 more
  63.  
  64. <?xml version="1.0"?>
  65.  
  66. <session-factory>
  67.  
  68. <!-- Database connection settings -->
  69. <property name="connection.driver_class">oracle.jdbc.OracleDriver</property>
  70. <property name="connection.url">jdbc:oracle:thin:@localhost:1521:wind</property>
  71. <property name="connection.username">mrp</property>
  72. <property name="connection.password">mrp</property>
  73.  
  74. <!-- JDBC connection pool (use the built-in) -->
  75. <property name="connection.pool_size">1</property>
  76.  
  77. <!-- SQL dialect -->
  78. <property name="dialect">org.hibernate.dialect.Oracle9iDialect</property>
  79.  
  80. <!-- Enable Hibernate's automatic session context management -->
  81. <property name="current_session_context_class">thread</property>
  82.  
  83. <!-- Disable the second-level cache -->
  84. <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
  85.  
  86. <!-- Echo all executed SQL to stdout -->
  87. <property name="show_sql">true</property>
  88.  
  89. <!-- Drop and re-create the database schema on startup -->
  90. <property name="hbm2ddl.auto">update</property>
  91.  
  92. <!-- to solve java.lang.NoSuchMethodException: org.hibernate.validator.ClassValidator error -->
  93. <property name="hibernate.validator.apply_to_ddl">false</property>
  94. <property name="hibernate.validator.autoregister_listeners">false</property>
  95. <property name="hibernate.jdbc.use_get_generated_keys">false</property>
  96.  
  97.  
  98.  
  99. <!-- List of XML mapping files -->
  100. <mapping resource="extalshibernatemappingsDocument.hbm.xml"/>
  101.  
  102.  
  103.  
  104.  
  105. </session-factory>
  106.  
  107. <hibernate-mapping>
  108.  
  109. </id>
  110. <property name="docNumber" column="DOC_NUMBER" type="string"/>
  111. <property name="docVersion" column="DOC_VERSION" type="string"/>
  112. <property name="xcgFile" column="XCG_FILE" type="string"/>
  113. <property name="xcgDate" column="XCG_DATE" type="date"/>
  114.  
  115. package ext.als.xcg.mrp.traceability.manager;
  116.  
  117. import java.util.List;
  118. import java.util.Date;
  119. import java.util.Iterator;
  120.  
  121. import org.hibernate.HibernateException;
  122. import org.hibernate.Session;
  123. import org.hibernate.Transaction;
  124. import org.hibernate.SessionFactory;
  125. import org.hibernate.cfg.Configuration;
  126.  
  127. import ext.als.xcg.mrp.traceability.beans.Document;
  128.  
  129. public class DocumentManager {
  130.  
  131. private static SessionFactory factory;
  132.  
  133. public static void main(String[] args) {
  134. try{
  135. factory = new Configuration().configure("ext\als\hibernate\hibernate.cfg.xml").buildSessionFactory();
  136. //factory = new Configuration().configure().buildSessionFactory();
  137.  
  138. }catch (Throwable ex) {
  139. System.err.println("Failed to create sessionFactory object." + ex);
  140. throw new ExceptionInInitializerError(ex);
  141. }
  142.  
  143. DocumentManager DM = new DocumentManager();
  144.  
  145. /* Add few employee records in database */
  146. Integer docID1 = DM.addDocument("DOC001", "00", "file_1.csv", new Date());
  147. Integer docID2 = DM.addDocument("DOC002", "02", "file_1.csv", new Date());
  148. Integer docID3 = DM.addDocument("DOC003", "05", "file_1.csv", new Date());
  149.  
  150. /* List down all the employees */
  151. DM.listDocuments();
  152.  
  153. /* Delete an employee from the database */
  154. DM.deleteDocument(docID2);
  155.  
  156. /* List down new list of the employees */
  157. DM.listDocuments();
  158. }
  159. /* Method to CREATE an employee in the database */
  160. public Integer addDocument(String docNumber, String docVersion, String xcgFile, Date xcgDate){
  161. Session session = factory.openSession();
  162. Transaction tx = null;
  163. Integer documentID = null;
  164. try{
  165. tx = session.beginTransaction();
  166. Document document = new Document(docNumber, docVersion, xcgFile, xcgDate);
  167. documentID = (Integer) session.save(document);
  168. tx.commit();
  169. }catch (HibernateException e) {
  170. if (tx!=null) tx.rollback();
  171. e.printStackTrace();
  172. }finally {
  173. session.close();
  174. }
  175. return documentID;
  176. }
  177.  
  178.  
  179.  
  180. /* Method to READ all the documents */
  181. public void listDocuments( ){
  182. Session session = factory.openSession();
  183. Transaction tx = null;
  184. try{
  185. tx = session.beginTransaction();
  186. List documents = session.createQuery("FROM Document").list();
  187. for (Iterator iterator =
  188. documents.iterator(); iterator.hasNext();){
  189. Document document = (Document) iterator.next();
  190. System.out.println("Document Number: " + document.getDocNumber());
  191. System.out.println("Document Version:" + document.getDocVersion());
  192. System.out.println("Xcg File:" + document.getXcgFile());
  193. System.out.println("Xcg Date:" + document.getXcgDate());
  194. }
  195. tx.commit();
  196. }catch (HibernateException e) {
  197. if (tx!=null) tx.rollback();
  198. e.printStackTrace();
  199. }finally {
  200. session.close();
  201. }
  202. }
  203.  
  204.  
  205. /* Method to DELETE an employee from the records */
  206. public void deleteDocument(Integer documentID){
  207. Session session = factory.openSession();
  208. Transaction tx = null;
  209. try{
  210. tx = session.beginTransaction();
  211. Document document =
  212. (Document)session.get(Document.class, documentID);
  213. session.delete(document);
  214. tx.commit();
  215. }catch (HibernateException e) {
  216. if (tx!=null) tx.rollback();
  217. e.printStackTrace();
  218. }finally {
  219. session.close();
  220. }
  221. }
  222. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement