Configuration config=new Configuration().configure();
SessionFactory session=config.buildSessionFactroy();

解决方案 »

  1.   

    to  ocean617(海洋) :怎样手工注册?
    to libin2722(禮物) :sessionFactory=new Configuration().configure().buildSessionFactory();跟你的一样的.有什么区别呀??问题是我的hibernate.cfg.xml 配置文件放在了src的目录下.是不是在启动的tomcat的时候会加载啊?不知道问题出在哪儿. 
    再有我的hibernate.cfg.xml和hibernate的映射文件都是自动生成的.通过hibernate synchonizer添加mapping reference和synchonize file的
      

  2.   

    private static String CONFIG_FILE_LOCATION = "com/hibernate/util/hibernate.cfg.xml";//配置文件的路径 默认的是找SRC目录下的hibernate.cfg.xml
    configuration = new Configuration();
    //configuration.configure(CONFIG_FILE_LOCATION);
    sessionFactory = configuration.configure(CONFIG_FILE_LOCATION).buildSessionFactory();
      

  3.   

    在应用程序中 当运行到
    SessionFactory sf = new Configuration().configure().buildSessionFactory();
    时报莫名的异常,而在web中没事是怎么回事啊?
    异常为:::
    java.lang.NoClassDefFoundError: javax/transaction/SystemException
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1055)
    at net.abe.SimpleTest.main(SimpleTest.java:17)
      

  4.   

    手工注册就是
    sessionFactory=new Configuration().configure().buildSessionFactory(“你的路径/配置文件名”)
      

  5.   

    晕死我了,还是不对的
    21718 [http-8081-Processor25] INFO  net.sf.hibernate.cfg.Environment  - Hibernate 2.1.8
    21765 [http-8081-Processor25] INFO  net.sf.hibernate.cfg.Environment  - hibernate.properties not found
    21843 [http-8081-Processor25] INFO  net.sf.hibernate.cfg.Environment  - using CGLIB reflection optimizer
    21859 [http-8081-Processor25] INFO  net.sf.hibernate.cfg.Environment  - using JDK 1.4 java.sql.Timestamp handling
    22000 [http-8081-Processor25] INFO  net.sf.hibernate.cfg.Configuration  - configuring from resource: /hibernate.cfg.xml
    22000 [http-8081-Processor25] INFO  net.sf.hibernate.cfg.Configuration  - Configuration resource: /hibernate.cfg.xml
    22031 [http-8081-Processor25] WARN  net.sf.hibernate.cfg.Configuration  - /hibernate.cfg.xml not found
      

  6.   

    指定的话也我把配置文件放到相应的位置上还是错
    35313 [http-8081-Processor25] INFO  net.sf.hibernate.cfg.Environment  - Hibernate 2.1.8
    35344 [http-8081-Processor25] INFO  net.sf.hibernate.cfg.Environment  - hibernate.properties not found
    35407 [http-8081-Processor25] INFO  net.sf.hibernate.cfg.Environment  - using CGLIB reflection optimizer
    35407 [http-8081-Processor25] INFO  net.sf.hibernate.cfg.Environment  - using JDK 1.4 java.sql.Timestamp handling
    35579 [http-8081-Processor25] INFO  net.sf.hibernate.cfg.Configuration  - configuring from resource: com/mypro/hibernate/hibernate.cfg.xml
    35579 [http-8081-Processor25] INFO  net.sf.hibernate.cfg.Configuration  - Configuration resource: com/mypro/hibernate/hibernate.cfg.xml
    35610 [http-8081-Processor25] WARN  net.sf.hibernate.cfg.Configuration  - com/mypro/hibernate/hibernate.cfg.xml not found
      

  7.   

    会不会是我的hibernate的包的问题啊?我用的是hibernate2.jar
      

  8.   

    会不会是你的hibernate.cfg.xml写的有问题