This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
hibernate project configuration in eclipse3.5 and netbeans6.8
hem kumar
Ranch Hand
Joined: Sep 05, 2005
Posts: 96
posted
0
Hi all, i am at my wits end for the last few days. I am working out the hibernate example provided in http://www.mastertheboss.com/en/hibernate/182-hibernate-tutorial.html . In eclipse its always coming as ExceptionInitializerError and null pointer exception. But with the netbeans its perfectly working out and i am able to insert the data to the mysql table. I am using the same Hibernate 3.3 lib and the project structure is also same in both the ides . If anybody has this strange experience please help me. Thank you.
.....For Every Problem There Is a Solution.....
Regards, Hem
hem kumar
Ranch Hand
Joined: Sep 05, 2005
Posts: 96
posted
0
hem kumar wrote:Hi all, i am at my wits end for the last few days. I am working out the hibernate example provided in http://www.mastertheboss.com/en/hibernate/182-hibernate-tutorial.html . In eclipse its always coming as ExceptionInitializerError and null pointer exception. But with the netbeans its perfectly working out and i am able to insert the data to the mysql table. I am using the same Hibernate 3.3 lib and the project structure is also same in both the ides . If anybody has this strange experience please help me. Thank you.
Hi jeane, here are the error stack trace from the eclipse environment-
Initial SessionFactory creation failed.java.lang.ExceptionInInitializerError
Exception in thread "main" java.lang.ExceptionInInitializerError at com.sample.SessionFactoryUtil.<clinit>(SessionFactoryUtil.java:18)
at com.sample.TestPerson.main(TestPerson.java:14)
Caused by: java.lang.ExceptionInInitializerError at com.sample.SessionFactoryUtil.<clinit>(SessionFactoryUtil.java:13)
... 1 more
Caused by: java.lang.NullPointerException at org.slf4j.LoggerFactory.singleImplementationSanityCheck(LoggerFactory.java:192)
at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:113)
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:269)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:242)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:255)
at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:152)
... 2 more
Here is the project structure with the lib used-
hem kumar
Ranch Hand
Joined: Sep 05, 2005
Posts: 96
posted
0
The strange thing which i not able to understand is, the same project with the same structure and lib configuration except that the hibernate.cfg.xml is in the default package instead of this conf folder as in eclipse is working perfectly without any errors in netbeans 6.8.
Hem,
The stack trace is telling you it can't find the hibernate config file. Meaning it is not in the classpath. Why don't you have it in the default package like you do in NetBeans since that works?
hem kumar
Ranch Hand
Joined: Sep 05, 2005
Posts: 96
posted
0
Jeanne
i have tried all sort of project configuration. Kept that hibernate.cfg.xml in the root / default src package and its also getting compiled and copied into the bin directory. But still am having the same error. Thanks for your time.
I am thinking of using NetBeans instead of wasting time in eclipse
Anyway this is the stack trace ->
Initial SessionFactory creation failed.java.lang.ExceptionInInitializerError
Exception in thread "main" java.lang.ExceptionInInitializerError at com.sample.SessionFactoryUtil.<clinit>(SessionFactoryUtil.java:18)
at com.sample.TestPerson.main(TestPerson.java:14)
Caused by: java.lang.ExceptionInInitializerError at com.sample.SessionFactoryUtil.<clinit>(SessionFactoryUtil.java:14)
... 1 more
Caused by: java.lang.NullPointerException at org.slf4j.LoggerFactory.singleImplementationSanityCheck(LoggerFactory.java:192)
at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:113)
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:269)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:242)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:255)
at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:152)
... 2 more
And here is the new structure-
Christian Dillinger
Ranch Hand
Joined: Jul 20, 2009
Posts: 172
posted
0
Thats an exception coming out of your logger. Have a look at the versions you are using. api-1.5.8 with an implementation 1.5.2. Try updating the last jar-File in your screenshot to 1.5.8.
hem kumar
Ranch Hand
Joined: Sep 05, 2005
Posts: 96
posted
0
yeah i changed the implementation to 1.5.8, but still there exists the same error. Its not able to read my hibernate.cfg.xml file. I dont know why?
hem kumar
Ranch Hand
Joined: Sep 05, 2005
Posts: 96
posted
0
The problem has been solved sometimes ago. So instead of keeping the hibernate.cfg.xml in any folder, we should keep it in the source folder which can be found if right clicked on the project name in eclipse. By that eclipse will automatically load it into classpath and the errors like class not found and InitializerExceptions wont occur. Thank you all.
hem kumar
Ranch Hand
Joined: Sep 05, 2005
Posts: 96
posted
0
hem kumar wrote:The problem has been solved sometimes ago. So instead of keeping the hibernate.cfg.xml in any folder, we should keep it in the source folder which can be found if right clicked on the project name in eclipse. Below is a screen shot for clarification. By that eclipse will automatically load it into classpath and the errors like class not found and InitializerExceptions wont occur. Thank you all.