22:47:46,192  INFO Environment:500 - Hibernate 3.2.0
Initial SessionFactory creation failed.java.lang.ExceptionInInitializerError
Exception in thread "main" java.lang.ExceptionInInitializerError
at util.HibernateUtil.<clinit>(HibernateUtil.java:18)============================================================================
HibernateUtil.java:
package util;import org.hibernate.*;
import org.hibernate.cfg.*;public class HibernateUtil { private static final SessionFactory sessionFactory; static {
try {
// Create the SessionFactory from hibernate.cfg.xml
sessionFactory = new Configuration().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;
}}

解决方案 »

  1.   

    少了第三方的jar,common-logging.jar
      

  2.   

    to 小小:
    二楼的错误信息是在添加common-logging.jar后产生的。
      

  3.   

    把common-logging.jar放在你的/WEB-INF/lib目录下,就可以了。
      

  4.   

    to zlinerxz():
    这个程序非web程序。
    并且我已经将hibernate3.2内的所有jar文件添加到classpath,所以应该不是包的引用问题。另外,同样的程序,我放到netbeans5.5中运行ok,而在eclipse3.2中却出现前面的问题。
    急!求解!
      

  5.   

    Initial SessionFactory creation failed.java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
    java.lang.NoClassDefFoundError: 明显是找不到类么,再查查。
      

  6.   

    to mengfanpp(梦凡):
    请看二楼!
    新的报错如下:
    22:47:46,192 INFO Environment:500 - Hibernate 3.2.0
    Initial SessionFactory creation failed.java.lang.ExceptionInInitializerError
    Exception in thread "main" java.lang.ExceptionInInitializerError
    at util.HibernateUtil.<clinit>(HibernateUtil.java:18)有关本程序的详细代码,可以参见:http://forum.hibernate.org/viewtopic.php?t=966926
    谢谢!
      

  7.   

    简单的说是你的SessionFactory 不能初始化!!!!!!
      你直接用Session session = SessionFactory.getSession();
    然后用session操作看看。  我的也出现过你的这样问题。
      

  8.   

    缺少apache的包,如:commons-beanutils.jar commons-collections.jar commons-dbcp.jar commons-digester.jar commons-fileupload.jar commons-io.jar commons-logging-1.1.jar commons-lang.jar commons-pool.jar commons-validator.jar jakarta-oro.jar
      

  9.   

    to bign_hdl(人善天不欺):
    盲目地添全这些包,有啥意义?为什么同样的代码在netbeans里可以跑,而在eclipse里却不行?
    请指教。
      

  10.   

    环境不同啊...配置好了那个IDE上都可以运行的
      

  11.   

    看一下classpath是否正确,估计还是缺少lib.