http://dom4j.sourceforge.net/
下载 dom4j

解决方案 »

  1.   

    谢谢,不过下载了那个包之后又有错误了java.lang.NullPointerException
    org.dao.imp.ChapterDaoImp.getChapterByID(ChapterDaoImp.java:23)
    org.action.ChapterAction.execute(ChapterAction.java:21)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    调用HibernateFactory的代码package org.dao.imp;import org.dao.ChapterDao;
    import org.hibernate.Query;
    import org.hibernate.Session;
    import org.hibernate.SessionFactory;
    import org.hibernate.Transaction;
    import org.model.Chapter;
    import org.util.HibernateSessionFactory;public class ChapterDaoImp implements ChapterDao
    {
    private SessionFactory sessionFactory; public void setSessionFactory(SessionFactory sessionFactory)
    {
    this.sessionFactory = sessionFactory;
    }

    public Chapter getChapterByID(Integer chapterID)
    {
    Session session=HibernateSessionFactory.getSession();
    Transaction ts=session.beginTransaction();
    Query query=session.createQuery("from Chapter where ChapterID=?"); 
    query.setParameter(0, chapterID);
    query.setMaxResults(1);
    Chapter chapter=(Chapter) query.uniqueResult();
    ts.commit();
    HibernateSessionFactory.closeSession();

    return chapter;
    }

    }
      

  2.   

    ClassNotFoundException找不到类异常
    缺少hibernate的jar包或hibernate的jar包与其他包有冲突,看看hibernate*.jar有几个
      

  3.   

    Transaction ts=session.beginTransaction(); 
    session 没获取成功。