I got the following error
java.lang.NoSuchMethodError: org.apache.log4j.Logger.log(Ljava/lang/String;Lorg/apache/log4j/Level;Ljava/lang/Object;Ljava/lang/Throwable;)Vwhile trying the Annotations.
I am using the jar files as:
hibernate-annotations.jar-3.4.0
hibernate-commons-annotations.jar-3.4.0
log4j.jar-1.2.15
slf4j-log4j13-1.0.jar
slf4j-api.jar 3.4.0
I have one utils class as:
Code:
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
public class HibernateUtil {
private static final SessionFactory sessionFactory;
static {
try {
// Create the SessionFactory from hibernate.cfg.xml
sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
} catch (Throwable ex) {
// Make sure you log the exception, as it might be swallowed
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
}
The flow is always catched in the line:
Code:
sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
and gives the above mentioned error. I am beginner in the hibernate field.
Please let me know what is the problem and how could it be solved.
Thanks,