我的HIBERNATE问题,请大家帮忙

zs_han 2006-10-09 09:33:10
我做了一个登录页面,后台数据库是ORACLE9I,可是一点登陆就出现如下错误,请大家帮忙看看是什么错误,我用的是tomcat5.5.1.7版本,hibernate是3版本,我是菜鸟,分不多
说明一下,数据库没有问题,因为我不用HIBERNATE,而直接用最原始连接池的办法是可以登陆的.


type Exception report


java.lang.NoClassDefFoundError: org/dom4j/io/SAXReader
org.hibernate.util.XMLHelper.createSAXReader(XMLHelper.java:35)
org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1168)
org.hibernate.cfg.Configuration.configure(Configuration.java:1112)
com.topsuntech.gUnit.gEU_test.entity.HibernateSessionFactory.currentSession(HibernateSessionFactory.java:54)
com.topsuntech.gUnit.gEU_test.service.UserInfoDAO.Check_UserInfo_by_name(UserInfoDAO.java:182)
com.topsuntech.gUnit.gEU_test.framework.actions.LoginAction.doLogin(LoginAction.java:85)
com.topsuntech.gUnit.gEU_test.framework.actions.LoginAction.execute(LoginAction.java:69)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
...全文
96 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
zs_han 2006-10-10
  • 打赏
  • 举报
回复
hibernate.cfg.xml文件如下:

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration>

<session-factory>
<property name="connection.username">luntan</property>
<property name="connection.url">jdbc:oracle:thin:@172.17.66.21:1521:orcl</property>
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property name="myeclipse.connection.profile">oracle_connect</property>
<property name="connection.password">luntan</property>
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<mapping resource="com/topsuntech/gUnit/gEU_test/entity/Userinfo.hbm.xml" />
<mapping resource="com/topsuntech/gUnit/gEU_test/entity/Education.hbm.xml"></mapping>

</session-factory>

</hibernate-configuration>
zs_han 2006-10-10
  • 打赏
  • 举报
回复
我的HibernateSessionFactory.class如下:

package com.topsuntech.gUnit.gEU_test.entity;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.cfg.Configuration;

/**
* Configures and provides access to Hibernate sessions, tied to the
* current thread of execution. Follows the Thread Local Session
* pattern, see {@link http://hibernate.org/42.html}.
*/
public class HibernateSessionFactory {

/**
* Location of hibernate.cfg.xml file.
* NOTICE: Location should be on the classpath as Hibernate uses
* #resourceAsStream style lookup for its configuration file. That
* is place the config file in a Java package - the default location
* is the default Java package.<br><br>
* Examples: <br>
* <code>CONFIG_FILE_LOCATION = "/hibernate.conf.xml".
* CONFIG_FILE_LOCATION = "/com/foo/bar/myhiberstuff.conf.xml".</code>
*/
private static String CONFIG_FILE_LOCATION = "/com/topsuntech/gUnit/gEU_test/entity/hibernate.cfg.xml";

/** Holds a single instance of Session */
private static final ThreadLocal threadLocal = new ThreadLocal();

/** The single instance of hibernate configuration */
private static final Configuration cfg = new Configuration();

/** The single instance of hibernate SessionFactory */
private static org.hibernate.SessionFactory sessionFactory;

/**
* Returns the ThreadLocal Session instance. Lazy initialize
* the <code>SessionFactory</code> if needed.
*
* @return Session
* @throws HibernateException
*/
public static Session currentSession() throws HibernateException {
Session session = (Session) threadLocal.get();

if (session == null || !session.isOpen()) {
if (sessionFactory == null) {
try {
cfg.configure(CONFIG_FILE_LOCATION);
sessionFactory = cfg.buildSessionFactory();
} catch (Exception e) {
System.err
.println("%%%% Error Creating SessionFactory %%%%");
e.printStackTrace();
}
}
session = (sessionFactory != null) ? sessionFactory.openSession()
: null;
threadLocal.set(session);
}

return session;
}

/**
* Close the single hibernate session instance.
*
* @throws HibernateException
*/
public static void closeSession() throws HibernateException {
Session session = (Session) threadLocal.get();
threadLocal.set(null);

if (session != null) {
session.close();
}
}
/**
* Default constructor.
*/
private HibernateSessionFactory() {
}

}
henrylove 2006-10-09
  • 打赏
  • 举报
回复
这样找不出来的!要看看你的配置文件!看看你是怎样映射的数据库!
最好把你的配置文件发下看看!

58,454

社区成员

发帖
与我相关
我的任务
社区描述
Java Eclipse
社区管理员
  • Eclipse
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧