首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Exception >

MyEclipse下hibernate 的java.lang.NoClassDefFoundError: net/sf/ehcache/CacheExcep

2014-01-26 
代码:public static void main(String[] args) {Users unew Users()Session sessionHibernateSessionFac

代码:
  public static void main(String[] args) {
  Users u=new Users();
  Session session=HibernateSessionFactory.currentSession();
  Transaction tran=session.beginTransaction();
  u.setUserName("aaa");
  u.setPassword("bbb");
  u.setRealName("ccc");
  u.setEmail("aaa@bbb.com");
  session.save(u);
  tran.commit();
  }   
    
  异常:
  log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
  log4j:WARN Please initialize the log4j system properly.
  Exception in thread "main" java.lang.NoClassDefFoundError: net/sf/ehcache/CacheException
  at java.lang.Class.getDeclaredConstructors0(Native Method)
  at java.lang.Class.privateGetDeclaredConstructors(Class.java:2328)
  at java.lang.Class.getConstructor0(Class.java:2640)
  at java.lang.Class.newInstance0(Class.java:321)
  at java.lang.Class.newInstance(Class.java:303)
  at org.hibernate.cfg.SettingsFactory.createCacheProvider(SettingsFactory.java:323)
  at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:219)
  at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1463)
  at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1004)
  at com.sunqihao.config.HibernateSessionFactory.currentSession(HibernateSessionFactory.java:49)
  at com.sunqihao.client.client.main(client.java:20)   
  

------解决方法--------------------------------------------------------
Exception in thread "main" java.lang.NoClassDefFoundError: net/sf/ehcache/CacheException
  这里提示你,你还没有定义类或是那个类没有默认的构造方法.
  查查在你的Users类或是在那里面是不是有一个
  public Users(){
  };
  方法

        

热点排行