hibernate, Configuration config = new Configuration().configure()时出错,请大家指点

07-08-29 javaGhost

我正在学习hibernate3,按照例子完成了代码,编译也通过.

但执行Configuration config = new Configuration().configure()的时候出错。

Exception in thread "main" java.lang.NoClassDefFoundError: org/dom4j/DocumentException

at com.rhb.bean.UserBusiness.getSession(Unknown Source)

at com.rhb.bean.UserBusiness.main(Unknown Source)

请大家指点一下

先谢谢了

1
javaGhost
2007-08-29 09:30

public Session getSession(){

  try{

    Configuration config = new Configuration().configure(); //执行此句出错

    SessionFactory sessionFactory = config.buildSessionFactory();

    session = sessionFactory.openSession();

  }catch(HibernateException e){

    e.printStackTrace();

  }

  return session;

}

public static void main(String[] args){

  try{

    UserBusiness ub = new UserBusiness();

    Session session = ub.getSession(); //执行此句出错

    ub.insert(session,"rhb","rhb");

    User user = ub.findByName(session,"rhb");

    ub.closeSession();

    System.out.println("the user is " + user.getUserName());

  }catch(HibernateException e){

    e.printStackTrace();

  }

}

javaGhost
2007-08-29 09:45

testHiberante

    |--bin

    |  |--com

    |  |  |--rhb

    |  |    |--bean

    |  |      |--AbstractUser.class

    |  |      |--HibernateSessionFactory.class

    |  |      |--User.class

    |  |      |--User.hbm.xml

    |  |      |--UserBusiness.class

    |  |--hibernate.cfg.xml

    |--lib

       |--hibernate3.jar

       |--mysql-connector-java-3.1.1-alpha-bin.jar

[该贴被javaGhost于2007年08月29日 09:53修改过]

javaGhost
2007-08-29 14:25

运行hibernate要这么多的包!

真不简单

banq
2007-08-30 10:39

只要贴出日志就可以,其他不必:

java.lang.NoClassDefFoundError: org/dom4j/DocumentException

表示运行环境缺少dom4j.jar包