2011-06-29 42 views
0

閱讀我的問題,這項工作在正常的動態Web項目 之前,我創建這樣梅索德Web服務:使用CFX 2.4 http://www.youtube.com/watch?v=o2Vjs8ylmFM 並與2.5動態Web模型版本,並在此當我運行冬眠由Web服務生成我得到一個異常當前客戶端的Web項目 這是它:與Web服務冬眠

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: Impossible de compiler la classe pour la JSP: 

     An error occurred at line: 1 in the generated java file 
     The type net.sf.hibernate.Session cannot be resolved. It is indirectly referenced from   required .class files 

     Une erreur s'est produite à la ligne: 16 dans le fichier jsp: /JSP/ebook/index.jsp 
      Session cannot be resolved to a type 
     13: <BODY> 
     14: <% 
     15: 
     16: Session hibernateSession = HibernateUtil.currentSession(); 
     17: Transaction tx = hibernateSession.beginTransaction(); 
     18: 
     19: Etudinat etudiant = new Etudinat(); 


     Une erreur s'est produite à la ligne: 16 dans le fichier jsp: /JSP/ebook/index.jsp 

和我的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("[email protected]"); 
    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
An error occurred at line: 1 in the generated java file 
    The type net.sf.hibernate.Session cannot be 

resolved. It is indirectly referenced from required .class files

顯然你的類路徑有問題。驗證你是否按要求導入了所有東西(這對我來說看起來是正確的),並且你的hibernate.jar在正確的文件夾中,並在執行過程中正確使用。

+0

我們更改了hibernate jar,並且我們用net.sf.hibernate.Session下載了另一個Hibernate2.0.3.jar,但sessionn是這個jar中的一個接口,而不是一個類,並且我們得到相同的錯誤plz能不能幫我 – David

+0

您是否驗證了jarfile是否在當前文件夾中並被正確加載? – bonifaz

+0

是的jar是在當前文件夾和它被正確加載,我打開eclipse,我發現session.class在那裏,但我得到了相同的錯誤 – David