hibernate类没有找到异常

时间:2011-06-29 18:25:15

标签: eclipse web-services hibernate jsp exception

在阅读我的问题之前,在普通的动态Web项目中工作 我创建像这样的方法的Web服务: http://www.youtube.com/watch?v=o2Vjs8ylmFM 使用CFX 2.4和2.5动态Web模型版本,当我在Web服务生成的当前客户端Web项目中运行hibernate时,我得到一个例外 就是这样:

Etat HTTP 500 - 

 --------------------------------------------------------------------------------

 type Rapport d''exception

 message 

  description Le serveur a rencontré une erreur interne () qui l'a empêché de   satisfaire la requête.

  exception 

 org.apache.jasper.JasperException: javax.servlet.ServletException:     java.lang.ExceptionInInitializerError
      org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:531)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:439)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:332)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)


    cause mère 

     javax.servlet.ServletException: java.lang.ExceptionInInitializerError
   org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:901)
   org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:830)
 org.apache.jsp.index_jsp._jspService(index_jsp.java:112)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:68)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:332)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)


     cause mère 

    java.lang.ExceptionInInitializerError
org.apache.jsp.index_jsp._jspService(index_jsp.java:73)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:68)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:332)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)


     cause mère 

     java.lang.RuntimeException: Problème de configuration : persistent class not found
Base.HibernateUtil.<clinit>(HibernateUtil.java:16)
org.apache.jsp.index_jsp._jspService(index_jsp.java:73)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:68)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:332)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)


    cause mère 

     net.sf.hibernate.MappingException: persistent class not found
net.sf.hibernate.cfg.Binder.bindClass(Binder.java:76)
net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:165)
net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1095)
net.sf.hibernate.cfg.Configuration.add(Configuration.java:230)
net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:252)
net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:273)
net.sf.hibernate.cfg.Configuration.configure(Configuration.java:841)
net.sf.hibernate.cfg.Configuration.configure(Configuration.java:792)
net.sf.hibernate.cfg.Configuration.configure(Configuration.java:732)
net.sf.hibernate.cfg.Configuration.configure(Configuration.java:719)
Base.HibernateUtil.<clinit>(HibernateUtil.java:14)
org.apache.jsp.index_jsp._jspService(index_jsp.java:73)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:68)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:332)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)


     cause mère 

    java.lang.ClassNotFoundException: Favorieensei
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1671)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1516)
java.lang.Class.forName0(Native Method)
java.lang.Class.forName(Class.java:169)
net.sf.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:268)
net.sf.hibernate.cfg.Binder.bindClass(Binder.java:73)
net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:165)
net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1095)
net.sf.hibernate.cfg.Configuration.add(Configuration.java:230)
net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:252)
net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:273)
net.sf.hibernate.cfg.Configuration.configure(Configuration.java:841)
net.sf.hibernate.cfg.Configuration.configure(Configuration.java:792)
net.sf.hibernate.cfg.Configuration.configure(Configuration.java:732)
net.sf.hibernate.cfg.Configuration.configure(Configuration.java:719)
Base.HibernateUtil.<clinit>(HibernateUtil.java:14)
org.apache.jsp.index_jsp._jspService(index_jsp.java:73)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:68)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:332)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)


     note La trace complète de la cause mère de cette erreur est disponible dans les fichiers journaux de Apache Tomcat/7.0.5.


   --------------------------------------------------------------------------------

   Apache Tomcat/7.0.5

我的班级hibernateUtil是:

package DBase;

import net.sf.hibernate.*;

import net.sf.hibernate.cfg.*;


 public class HibernateUtil {

 private static final SessionFactory sessionFactory;

 static {
 try {
 // Crée la SessionFactory
 sessionFactory =
 new Configuration().configure().buildSessionFactory();
 } catch (HibernateException ex) {
 throw new RuntimeException("Problème de configuration : "
 + ex.getMessage(), ex);
 }
 }

 public static final ThreadLocal session = new ThreadLocal();

  public static Session currentSession()
  throws HibernateException {
  Session s = (Session) session.get();
 // Ouvre une nouvelle Session, si ce Thread n'en a aucune
 if (s == null) {
 s = sessionFactory.openSession();
 session.set(s);
 }
 return s;
}

我的hibernate.cfg.xml页面是:

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

<hibernate-configuration>
<session-factory >

<!-- local connection properties -->
<property name="hibernate.connection.url">jdbc:mysql://localhost/ebook</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">162826</property>
<!-- property name="hibernate.connection.pool_size"></property -->

<!-- dialect for MySQL -->
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>



 <!-- Echo all executed SQL to stdout -->
 <property name="show_sql">true</property>

  <property name="current_session_context_class">thread</property>

  <mapping resource="DBase/Favorieensei.hbm" />
  <mapping resource="DBase/Ajouter.hbm" />
  <mapping resource="DBase/Favorie.hbm" />
  <mapping resource="DBase/Enseignant.hbm" />

这是我的页面jsp

<%@page import="DBase.HibernateUtil"%>
<%@ page import="java.io.*" %> 
<%@ page import="java.util.*" %> 
<%@ page import="DBase.*" %> 
<%@ page import="net.sf.hibernate.*" %> 
<%@ page import="net.sf.hibernate.cfg.*" %> 

<HTML> 
<HEAD> 
<title>Greetings!</title> 
</HEAD>  
  <BODY> 
<%

 Session hibernateSession = HibernateUtil.currentSession();
  Transaction tx = hibernateSession.beginTransaction(); 

  Etudinat etudiant = new Etudinat();
  etudiant.setUserName("davido");
 etudiant.setPassword("mioo");
  etudiant.setQuestion("best music");
   etudiant.setAnswer("rock");
   etudiant.setEmail("david@live.fr");
  etudiant.setNom(".....");
  etudiant.setPrenom("....");
  etudiant.setSexe("Homme");

   etudiant.setIDFilliere(Filliere.INFORMATIQUE);
  hibernateSession.save(etudiant); 
  tx.commit();
  HibernateUtil.closeSession();


  %> 


  <br> 
 <br> 
 <br> 
 <br> 
  <table width="400" border="0" cellspacing="1" cellpadding="0" align="center" class="tableBox"> 
  <tr> 
  <td CLASS="bluebanner" align="center"> Greetings, </TD> 
    </tr> 
  </table> 
    </BODY> 
    </HTML>

这是我的screan镜头

screan shot about hibernate

PLZ帮助我们按时运行我还有3个完成它

1 个答案:

答案 0 :(得分:2)

堆栈跟踪清楚地表明缺少类Favorieensei。您需要检查项目结构。

相关问题