Posts

Showing posts with the label sessionfactory

ExceptionInInitializerError in Hibernate

As part of the Hibernate practice, I have faced the  Exception in thread "main" java.lang.ExceptionInInitializerError  at the time of creating the SessionFactory. Here is the full stacktrace which I have captured from console. INFO: HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException SessionFactory creation failed.org.hibernate.boot.registry.classloading.spi.ClassLoadingException : Unable to load class [com.javatbrains.sample.User] Exception in thread "main" java.lang.ExceptionInInitializerError        at com.jtb.util.HibernateUtil.buildSessionFactory( HibernateUtil.java:13 )        at com.jtb.util.HibernateUtil.getSessionFactory( HibernateUtil.java:18 )        at com.jtb.test.DeleteUser.main( DeleteUser.java:11 ) Caused by: org.hibernate.boot.registry.classloading.spi.ClassLoadingException : Unable to load class [com.javatbrains.sample.User]        at org.hibernate.

SessionFactory creation failed.java.lang.NoSuchFieldError: namingStrategy

While creating the SessionFactory in Hibernate I have faced lot's of issues. This is also one the exception which I have faced, SessionFactory creation failed.java.lang.NoSuchFieldError: namingStrategy Exception in thread "main" java.lang.ExceptionInInitializerError        at com.jtb.util.HibernateUtil.buildSessionFactory( HibernateUtil.java:13 )        at com.jtb.util.HibernateUtil.getSessionFactory( HibernateUtil.java:18 )        at com.jtb.test.DeleteUser.main( DeleteUser.java:11 ) Caused by: java.lang.NoSuchFieldError: namingStrategy        at org.hibernate.cfg.AnnotationConfiguration.reset( AnnotationConfiguration.java:237 )        at org.hibernate.cfg.Configuration.<init>( Configuration.java:125 )        at org.hibernate.cfg.Configuration.<init>( Configuration.java:119 )        at org.hibernate.cfg.AnnotationConfiguration.<init>( AnnotationConfiguration.java:96 )        at com.jtb.util.HibernateUtil.buildSessionFactory( Hiber

SessionFactory creation failed.java.lang.NoClassDefFoundError

While practicing the Hibernate auto increment example, I have faced lots of issues. In that one of the thing is SessionFactory creation error. Error stack trace is as follows, SessionFactory creation failed.java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory Exception in thread "main" java.lang.ExceptionInInitializerError        at com.jtb.util.HibernateUtil.buildSessionFactory( HibernateUtil.java:15 )        at com.jtb.util.HibernateUtil.<clinit>( HibernateUtil.java:8 )        at com.jtb.test.DeleteUser.main( DeleteUser.java:11 ) Caused by: java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory        at org.hibernate.cfg.AnnotationConfiguration.<clinit>( AnnotationConfiguration.java:65 )        at com.jtb.util.HibernateUtil.buildSessionFactory( HibernateUtil.java:12 )        ... 2 more Caused by: java.lang.ClassNotFoundException : org.apache.commons.logging.LogFactory        at java.net.URLClassLoad