Posts

Showing posts with the label errors in java

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

Java Networking Connection Refused: Connect

Java Networking “Connection Refused: Connect” problem will get in normal production environments. Here, we are mentioning our best to problem with answer and steps to solve the problem. In the below mentioned source code what it is running in the client and server instances. Server: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 import java.io.* ; import java.net.* ; public class Test { public static void main ( String [] args ) { final int PORT_NUMBER = 44574 ; while ( true ) { try { //Listen on port ServerSocket serverSock = new ServerSocket ( PORT_NUMBER ); System . out . println ( "Listening..." ); //Get connection Socket clientSock = serverSock . accept (); System . out . println ( "Connected client" ); //Get input BufferedReader br = new BufferedReader ( new InputStreamReader ( clientSock