您现在的位置: 爱51代码网 >> 范文 >> 文章正文
java.lang.NoClassDefFoundError.couldn't initialize class HibernateUtil

 java.lang.NoClassDefFoundError.couldn't initialize class HibernateUtil

项目使用Struts1.2+Hibernate3.3来做的。之前部署使用完全没有问题。最近由于项目需要,又添加了几个数据表,同时添加了相应的entity和.hbm.xml文件,并且在hibernate.cfg.xml中添加了相应的记录。

结果,系统就bug掉了。。。。报错为: java.lang.NoClassDefFoundError.couldn't initialize class HibernateUtil
HibernateUtil是读取hibernate.cfg.xml文件的类。

但是如果在hibernate.cfg.xml中删掉新添加的数据表记录,系统正常工作;

在线等啊~~~~急!

附代码如下:
1. HibernateUtil.java; 2. hibernate.cfg.xml 3. jar包截图

1. HibernateUtil.java

Java code?package com.usensor.hibernate.util;     import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration;   public class HibernateUtil {     private static SessionFactory sessionFactory;     public HibernateUtil(){}         static{                 Configuration cfg = new Configuration();                 cfg.configure();//cfg.configure("Hibernate.cfg.xml"),用于读取配置文件                 sessionFactory = cfg.buildSessionFactory();           }         public static SessionFactory getSessionFactory() {             return sessionFactory;         }         public static Session getSession(){             return sessionFactory.openSession();         }         public static void closeSession(Session session){             if(session!=null){                 if(session.isOpen())                     session.close();             }                       }           } 


2. hibernate.cfg.xml

Plain Text code?<?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="proxool.pool_alias">proxoolPool</property>     <property name="proxool.xml">WEB-INF/proxoolconf.xml</property>     <property name="hibernate.proxool.existing_pool">true</property>     <property name="connection.provider_class">         org.hibernate.connection.ProxoolConnectionProvider     </property>     <property name="connection.driver_class">         com.mysql.jdbc.Driver     </property>         <property name="connection.characterEncoding">UTF-8</property>     <property name="dialect">         org.hibernate.dialect.MySQLDialect     </property>     <property name="connection.url"></property>     <mapping resource="com/usensor/user/entity/UsrUser.hbm.xml" />     <mapping resource="com/usensor/user/entity/UsrAdmin.hbm.xml" />     <mapping resource="com/usensor/feed/entity/FeedInfo.hbm.xml" />     <mapping resource="com/usensor/feed/entity/FeedDatastream.hbm.xml" />     <mapping resource="com/usensor/feed/entity/FeedData.hbm.xml" />     <mapping resource="com/usensor/utils/entity/MngNotice.hbm.xml" />     <mapping resource="com/usensor/user/entity/UsrFavfeed.hbm.xml" />     <mapping resource="com/usensor/user/entity/UsrMsg.hbm.xml" />     <mapping resource="com/usensor/utils/entity/Searchkey.hbm.xml" />     <mapping resource="com/usensor/feed/entity/FeedTriggers.hbm.xml" />     <mapping resource="com/usensor/user/entity/UsrPubfeed.hbm.xml" />     <mapping resource="com/usensor/app/entity/MngApplication.hbm.xml" />     <mapping resource="com/usensor/feed/entity/MngRecfeed.hbm.xml" />     <mapping resource="com/usensor/utils/entity/ContactUs.hbm.xml" />     <mapping resource="com/usensor/feed/entity/DelDataBackup.hbm.xml" />     <mapping resource="com/groupus/entity/Group.hbm.xml" />     <mapping resource="com/groupus/entity/Message.hbm.xml" />     <mapping resource="com/groupus/entity/Member.hbm.xml" />     <mapping resource="com/usensor/classify/entity/AppSrt.hbm.xml" />     <mapping resource="com/usensor/classify/entity/UsrCls.hbm.xml" />         <!-- 以下五条是新添加的-->     <mapping resource="com/usensor/archi/entity/Area.hbm.xml" />     <mapping resource="com/usensor/archi/entity/Architecture.hbm.xml" />     <mapping resource="com/usensor/archi/entity/ArchiInfo.hbm.xml" />     <mapping resource="com/usensor/archi/entity/PicInfo.hbm.xml" />     <mapping resource="com/usensor/archi/entity/RouteInfo.hbm.xml" />   </session-factory>   </hibernate-configuration>
不应该啊,这些新的都是自动生成的吧

关了MyEclipse重新打开看看 java.lang.NoClassDefFoundError.couldn't initialize class HibernateUtil

看你写的也没错啊,是不是HibernateUtil的路径有问题呢? 把tomact work和webapps包中的项目目录删除,重新启动tomact编译

 

  • 上一篇文章:

  • 下一篇文章: 没有了
  • 最新文章 热点文章 相关文章
    undefined reference timer_crea
    linux文件/usr/lib破坏了,还原后
    linux上运行system函数时,print
    Failed to open eth0
    android手机无法与eclipse或电脑
    C/C++洗牌算法源代码
    servlet技术实现用户名唯一的验证
    E-business suite system servic
    ZOJ 3700 Ever Dream 文章中单词
    TortoiseGit和msysGit安装及使用
    ZOJ 3700 Ever Dream 文章中单词
    TortoiseGit和msysGit安装及使用
    sharepoint 2010 获取用户信息Us
    mysql主从同步延迟方案解决的学习
    生日旅行总结
    中小板生日快乐随感
    送生日快乐桑葚乳酪小蛋糕
    写给女儿的生日快乐
    总分公司财务核算
    恢复使用繁体字可行性研究报告
    java从.dat文件中读取数据
    JDWP Unable to get JNI 1.2
    富文本控件怎么把数据存放到
    Unresolved compilation pro
    正则表达式如何解析JSON
    Ajax异步调用后台 实现简单的
    定时将SQL SERVER2000中一个
    Exception in thread "Timer
    Exception sending context 
    Eclipse下启动tomcat报错:/
     



    设为首页 | 加入收藏 | 网站地图 | 友情链接 |