JiveJdon Community Forums
在线461人   首页   主题表   培训咨询   标签   精华   查搜   注册    登陆 RSS
首页 » 论坛 » 开源项目大家谈
???en_US.forumThreadPrev.name??? 上一主题
  Go back to the topic 返回本主题   Go back to the topic listing返回主题列表
???en_US.forumThreadNext.name??? 下一主题
Go 总共有 1 回复 / 1
 发表新帖子   回复该主题贴
aaronbai

悄悄话
发表文章: 1
注册时间: 2006年12月06日 18:49
求助:一个小hibernate问题,在线等待!谢谢!! 2006年12月06日 18:54 到本帖网址 加入本帖到收藏夹 发送到手机 回复该主题
标签列表
出错信息:

java.lang.NoClassDefFoundError: org/dom4j/DocumentException
at query.HibernateUtil.<clinit>(HibernateUtil.java:26)
at query.QueryFrame.getEmployees(QueryFrame.java:28)
at query.QueryFrame.actionPerformed(QueryFrame.java:63)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
at javax.swing.plaf.basic.BasicB




出错提示中的at query.HibernateUtil.<clinit>(HibernateUtil.java:26)是这句
sessionFactory=new Configuration().configure().buildSessionFactory();

具体的程序如下:


package query;
import query.HibernateSessionFactory;



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

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;



public class HibernateUtil {

private static Log log=LogFactory.getLog(HibernateUtil.class);

private static final SessionFactory sessionFactory;
static {
try {



sessionFactory=new Configuration().configure().buildSessionFactory();
} catch (Throwable ex) {
ex.printStackTrace();// TODO: handle exception
throw new ExceptionInInitializerError(ex);
}

}

public static final ThreadLocal session=new ThreadLocal();

public static Session currentSession()throws HibernateException{
Session s=(Session)session.get();
if(s==null||!s.isOpen()){
s=sessionFactory.openSession();
session.set(s);
}


return s;

}



public static void closeSession()throws HibernateException{
Session s=(Session)session.get();
session.set(null);
if(s!=null)s.close();
}
}










Hibernate配置文件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">test_root</property>
<property name="connection.url">
jdbc:mysql://localhost:3306/test
</property>
<property name="dialect">
org.hibernate.dialect.MySQLDialect
</property>
<property name="myeclipse.connection.profile">
mysqlprofile
</property>
<property name="connection.password">test_root</property>
<property name="connection.driver_class">
org.gjt.mm.mysql.Driver
</property>
<property name="max_fetch_depth">1</property>
<mapping resource="com/model.hbm.xml" />

</session-factory>

</hibernate-configuration>


另一个配置文件:

model.hbm.xml

<?xml version="1.0"?>
<!DOCTYPE Hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse - Hibernate Tools
-->
<hibernate-mapping>


<class name="query.Employee" table="employee" catalog="test">
<id name="id" type="java.lang.Integer">
<column name="id" />
<generator class="assigned" />
</id>

<property name="username" type="java.lang.String">
<column name="name" />
</property>

<property name="department" type="java.lang.String">
<column name="department" />
</property>
<property name="salary" type="java.lang.Long">
<column name="department" />
</property>

</class>
</hibernate-mapping>
banq

悄悄话
发表文章: 9481
注册时间: 2002年08月03日 17:08
Re: 求助:一个小hibernate问题,在线等待!谢谢!! 2006年12月14日 16:08 到本帖网址 加入本帖到收藏夹 发送到手机 回复该主题
> org/dom4j/DocumentException
classpath没有dom4j这个包
这个主题有 1 回复 / 1Go
???en_US.forumThreadPrev.name??? 上一主题
  Go back to the topic 返回本主题   Go back to the topic listing返回主题列表    返回页首返回页首
???en_US.forumThreadNext.name??? 下一主题
热点TAG: AOP cache 缓存 DDD EJB 集群 设计模式 Hibernate IOC JiveJdon OO RBAC Seam Spring Struts
正在读取,请等待...
google yahoo 新浪ViVi 365Key网摘 天极网摘 CSDN网摘 添加到百度搜藏 POCO网摘 博采网摘
查询本论坛内 回复超过的热门帖子
     回复该主题贴
标题
 
粗体 斜体 下划线 插入图片 插入代码 插入url链接 插入附件
内容
  发贴前查询 标签列表勿重复发表问题

RSS 手机阅读 add to google add to yahoo
解惑之道在J道 ,打造中国最具影响力的的企业软件社区
OpenSource JIVEJDON v3.0 Powered by JdonFramework Code © 2002-08 jdon.com
anti spam