2015-04-06 31 views
0

HY大家 我需要你的幫助來解決我的問題,我不知道爲什麼它不工作: 中出現錯誤:java.lang.noclassdeffounderror在hibenateutil

java.lang.NoClassDefFoundError: Could not initialize class tn.ooredoo.kpi.util.HibernateUtil - Stack Trace

javax.faces.el.EvaluationException: java.lang.NoClassDefFoundError: Could not initialize class tn.ooredoo.kpi.util.HibernateUtil at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:98) at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:98) at javax.faces.component.UICommand.broadcast(UICommand.java:311) at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:781) at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1246) at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:77) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97) at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:114) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:308) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:744) Caused by: java.lang.NoClassDefFoundError: Could not initialize class tn.ooredoo.kpi.util.HibernateUtil at tn.ooredoo.kpi.dao.EmployeDao.getSessionFactory(EmployeDao.java:34) at tn.ooredoo.kpi.dao.EmployeDao.(EmployeDao.java:30) at tn.ooredoo.kpi.controller.LoginCtr.connecter(LoginCtr.java:37) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.apache.el.parser.AstValue.invoke(AstValue.java:278) at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:274) at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:102) at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:84) ... 24 more

+0

你究竟在做什麼? – niyasc 2015-04-06 12:45:23

+0

顯示EmployeDao – Nimesh 2015-04-06 12:46:20

+0

的代碼我的問題是這個錯誤,我只是把現在的代碼employeDao – 2015-04-06 13:31:27

回答

0

「tn.ooredoo。 kpi.util.HibernateUtil「 - 無法找到此類。

這是來自未知類的引用的結果(您沒有包含完整的錯誤,所以不可能完全說出所發生的事情)

我可以肯定地說是你的類對tn.ooredoo.kpi.util.HibernateUtil有一個間接的引用,並且找不到這個類 - 它看起來不能被找到的類是可能在構建期間被排除的一部分庫或運行(最有可能運行)。

+0

謝謝你的方式,但你的意思是包括完整的錯誤? – 2015-04-06 12:47:29

+0

「... 24更多」 - 記錄器沒有輸出完整的錯誤,但仍有24行留下錯誤。 – Wayne 2015-04-06 12:56:19

+0

我怎麼能看到所有24個更多的記錄器? – 2015-04-06 12:58:59

0
public class EmployeDao { 

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

private final SessionFactory sessionFactory = getSessionFactory(); 

protected SessionFactory getSessionFactory() { 
    try { 
     return (SessionFactory) HibernateUtil.sessionFactory; 
    } catch (Exception e) { 
     log.error("Could not locate SessionFactory in JNDI", e); 
     throw new IllegalStateException(
       "Could not locate SessionFactory in JNDI"); 
    } 
} 

public void persist(Employe transientInstance) { 
    log.debug("persisting Employe instance"); 
    try { 
     sessionFactory.getCurrentSession().persist(transientInstance); 
     log.debug("persist successful"); 
    } catch (RuntimeException re) { 
     log.error("persist failed", re); 
     throw re; 
    } 
} 

private void openTransaction() { 
    sessionFactory.getCurrentSession().beginTransaction(); 
} 

private void closeTransaction() { 
    sessionFactory.getCurrentSession().getTransaction().commit(); 
} 

public void attachDirty(Employe instance) { 
    log.debug("attaching dirty Employe instance"); 
    try { 
     sessionFactory.getCurrentSession().saveOrUpdate(instance); 
     log.debug("attach successful"); 
    } catch (RuntimeException re) { 
     log.error("attach failed", re); 
     throw re; 
    } 
} 

public void attachClean(Employe instance) { 
    log.debug("attaching clean Employe instance"); 
    try { 
     sessionFactory.getCurrentSession().lock(instance, LockMode.NONE); 
     log.debug("attach successful"); 
    } catch (RuntimeException re) { 
     log.error("attach failed", re); 
     throw re; 
    } 
} 

public void delete(Employe persistentInstance) { 
    log.debug("deleting Employe instance"); 
    try { 
     sessionFactory.getCurrentSession().delete(persistentInstance); 
     log.debug("delete successful"); 
    } catch (RuntimeException re) { 
     log.error("delete failed", re); 
     throw re; 
    } 
} 

public Employe merge(Employe detachedInstance) { 
    log.debug("merging Employe instance"); 
    try { 
     Employe result = (Employe) sessionFactory.getCurrentSession() 
       .merge(detachedInstance); 
     log.debug("merge successful"); 
     return result; 
    } catch (RuntimeException re) { 
     log.error("merge failed", re); 
     throw re; 
    } 
} 

public Employe findById(int id) { 
    log.debug("getting Employe instance with id: " + id); 
    try { 
     openTransaction(); 
     Employe instance = (Employe) sessionFactory.getCurrentSession() 
       .get("tn.ooredoo.kpi.model.Employe", id); 
     if (instance == null) { 
      log.debug("get successful, no instance found"); 
     } else { 
      log.debug("get successful, instance found"); 
     } 
     return instance; 
    } catch (RuntimeException re) { 
     log.error("get failed", re); 
     throw re; 
    } finally { 
     closeTransaction(); 
    } 
} 

public List findByExample(Employe instance) { 
    log.debug("finding Employe instance by example"); 
    try { 
     List results = sessionFactory.getCurrentSession() 
       .createCriteria("tn.ooredoo.kpi.dao.Employe") 
       .add(Example.create(instance)).list(); 
     log.debug("find by example successful, result size: " 
       + results.size()); 
     return results; 
    } catch (RuntimeException re) { 
     log.error("find by example failed", re); 
     throw re; 
    } 
} 

public List findByProprety(Employe instance) { 
    log.debug("finding Employe instance by example"); 
    try { 
     openTransaction(); 
     Criterion critere = Expression.eq("loginEmploye", 
       instance.getLoginEmploye()); 
     List results = sessionFactory.getCurrentSession() 
       .createCriteria("tn.ooredoo.kpi.model.Employe") 
       .add(critere).list(); 
     log.debug("find by example successful, result size: " 
       + results.size()); 
     return results; 
    } catch (RuntimeException re) { 
     log.error("find by example failed", re); 
     throw re; 
    } finally { 
     closeTransaction(); 
    } 
} 
}