开发者

hibernate class not found exception

before reading my problem this work in a normal dynamic web project i create a web service like this methode: http://www.youtube.com/watch?v=o2Vjs8ylmFM using CFX 2.4 and with the 2.5 dynamic web model version and when i run hibernate in this current client web project generated by the web service i get an exception this is it:

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èr开发者_StackOverflow中文版e 

     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

and my class hibernateUtil is :

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;
}

and my hibernate.cfg.xml page is:

<?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" />

and this is my page 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>

this is my screan shot

hibernate class not found exception

plz help us we are running on time i have 3 left to finish it


The stack trace clearly states that class Favorieensei is missing. You need to check your project structure.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜