aspose file tools*
The moose likes Object Relational Mapping and the fly likes Initial SessionFactory creation failed.java.lang.ExceptionInInitializerError Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Initial SessionFactory creation failed.java.lang.ExceptionInInitializerError" Watch "Initial SessionFactory creation failed.java.lang.ExceptionInInitializerError" New topic
Author

Initial SessionFactory creation failed.java.lang.ExceptionInInitializerError

naveed garg
Greenhorn

Joined: Mar 01, 2012
Posts: 15

when i execute my hibernate application in eclipse than i got this error please help me :


Initial SessionFactory creation failed.java.lang.ExceptionInInitializerError
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.vaannila.util.HibernateUtil.<clinit>(HibernateUtil.java:14)
at com.vaannila.student.Main.main(Main.java:12)
Caused by: java.lang.ExceptionInInitializerError
at com.vaannila.util.HibernateUtil.<clinit>(HibernateUtil.java:10)
... 1 more
Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: No suitable Log constructor [Ljava.lang.Class;@47b480 for org.apache.commons.logging.impl.Log4JLogger (Caused by java.lang.NoClassDefFoundError: org/apache/log4j/Category) (Caused by org.apache.commons.logging.LogConfigurationException: No suitable Log constructor [Ljava.lang.Class;@47b480 for org.apache.commons.logging.impl.Log4JLogger (Caused by java.lang.NoClassDefFoundError: org/apache/log4j/Category))
at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:543)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:209)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:120)
... 2 more
Caused by: org.apache.commons.logging.LogConfigurationException: No suitable Log constructor [Ljava.lang.Class;@47b480 for org.apache.commons.logging.impl.Log4JLogger (Caused by java.lang.NoClassDefFoundError: org/apache/log4j/Category)
at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:413)
at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529)
... 6 more
Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Category
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.getConstructor(Unknown Source)
at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:410)
... 7 more
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Category
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at sun.misc.Launcher$ExtClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 12 more
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3775

Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: No suitable Log constructor [Ljava.lang.Class;@47b480 for org.apache.commons.logging.impl.Log4JLogger (Caused by java.lang.NoClassDefFoundError: org/apache/log4j/Category) ...

The jar file for logging is missing in your class path, add it (and any other missing from the required list in your Hibernate readme file) to the classpath...


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
naveed garg
Greenhorn

Joined: Mar 01, 2012
Posts: 15
thanks , but now i am getting problem in jpa example


log4j:WARN No appenders could be found for logger (org.hibernate.cfg.annotations.Version).
log4j:WARN Please initialize the log4j system properly.
Initial SessionFactory creation failed.org.hibernate.HibernateException: /hibernate.cfg.xml not found
Exception in thread "main" java.lang.ExceptionInInitializerError
at net.roseindia.HibernateUtil.<clinit>(HibernateUtil.java:15)
at net.roseindia.Example1.main(Example1.java:14)
Caused by: org.hibernate.HibernateException: /hibernate.cfg.xml not found
at org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:147)
at org.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:1405)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1427)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1414)
at net.roseindia.HibernateUtil.<clinit>(HibernateUtil.java:11)
... 1 more
E Armitage
Rancher

Joined: Mar 17, 2012
Posts: 761
    
    9
The class net.roseindia.HibernateUtil is failing to find the /hibernate.cfg.xml.
you could try and see where that class expects that file to be.
Me? I would not use anything from roseindia ...
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3775

Initial SessionFactory creation failed.org.hibernate.HibernateException: /hibernate.cfg.xml not found
Exception in thread "main" java.lang.ExceptionInInitializerError

Place the hibernate.cfg.xml file at the root of the classpath (i.e.: inside classes folder by default).
 
Don't get me started about those stupid light bulbs.
 
subject: Initial SessionFactory creation failed.java.lang.ExceptionInInitializerError
 
Similar Threads
Sorting Problem in JSP
Error after upgrading from SOA 10.1.3.1 to 10.1.4.1 (commons-loging.jar)
Plugin Axis to Tomcat
.getJSON not returning any response.
Log4j in Weblogic - ClassNotFoundException please help