Bonjours ,
je travaille sous Netbeans 6.5,j'utilise hibernate et visual jsf dans mon projet.
j'ai rencontré un probleme apres que le projet marche bien déjà.c'est qu'un exception se déclenche à chaque fois que j'essaye d'ouvrir une session via le fichier HibernateUtil.java.je rappelle que le projet marche bien au début j'ai tous configuré et voila les fichiers que j'utilise :
la méthode qui fait appelle à une session :
public String button1_action() {
// TODO: Process the action. Return value is a navigation
// case name where null will return to the same page.
Session ses=HibernateUtil.getSessionFactory().getCurrentSession();
//ses.close();
return null;
}
le fichier HibernateUtil:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package prj59;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.SessionFactory;
/**
* Hibernate Utility class with a convenient method to get Session Factory object.
*
* @author AIT BENMOUH
*/
public class HibernateUtil {
private static final SessionFactory sessionFactory;
static {
try {
// Create the SessionFactory from standard (hibernate.cfg.xml)
// config file.
sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
} catch (Throwable ex) {
// Log the exception.
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
}
le fichier hibernate.cfg.xml :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/ormva</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.current_session_context_class">thread</property>
<mapping resource="Entity/PieceRechange.hbm.xml"/>
<mapping resource="Entity/Mission.hbm.xml"/>
<mapping resource="Entity/Kilommetrage.hbm.xml"/>
<mapping resource="Entity/Service.hbm.xml"/>
<mapping resource="Entity/Vehicule.hbm.xml"/>
<mapping resource="Entity/Carburant.hbm.xml"/>
<mapping resource="Entity/Administrateur.hbm.xml"/>
<mapping resource="Entity/Vignette.hbm.xml"/>
<mapping resource="Entity/Projet.hbm.xml"/>
<mapping resource="Entity/Personne.hbm.xml"/>
<mapping resource="Entity/AtelierRechange.hbm.xml"/>
<mapping resource="Entity/AtelierRechange.hbm.xml"/>
<mapping resource="Entity/PieceRechange.hbm.xml"/>
<mapping resource="Entity/Service.hbm.xml"/>
<mapping resource="Entity/Carburant.hbm.xml"/>
<mapping resource="Entity/Mission.hbm.xml"/>
<mapping resource="Entity/Vehicule.hbm.xml"/>
<mapping resource="Entity/Vignette.hbm.xml"/>
<mapping resource="Entity/Projet.hbm.xml"/>
<mapping resource="Entity/Administrateur.hbm.xml"/>
<mapping resource="Entity/Personne.hbm.xml"/>
<mapping resource="Entity/Kilommetrage.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Et voila l'exception qui me génère à l'exécution :
type Rapport d'exception
message
description Le serveur a rencontr� une erreur interne () qui l'a emp�ch� de satisfaire la requ�te.
exception
com.sun.rave.web.ui.appbase.ApplicationException: #{Personne.button1_action}: java.lang.ExceptionInInitializerError
com.sun.rave.web.ui.appbase.faces.ViewHandlerImpl.cleanup(ViewHandlerImpl.java:603)
com.sun.rave.web.ui.appbase.faces.ViewHandlerImpl.renderView(ViewHandlerImpl.java:311)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
com.sun.faces.extensions.avatar.lifecycle.PartialTraversalLifecycle.render(PartialTraversalLifecycle.java:106)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
com.sun.webui.jsf.util.UploadFilter.doFilter(UploadFilter.java:267)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
cause m�re
javax.faces.FacesException: #{Personne.button1_action}: java.lang.ExceptionInInitializerError
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:107)
com.sun.rave.web.ui.appbase.faces.ActionListenerImpl.processAction(ActionListenerImpl.java:91)
javax.faces.component.UICommand.broadcast(UICommand.java:383)
com.sun.webui.jsf.component.WebuiCommand.broadcast(WebuiCommand.java:160)
javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:447)
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:752)
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
com.sun.faces.extensions.avatar.lifecycle.PartialTraversalLifecycle.execute(PartialTraversalLifecycle.java:94)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
com.sun.webui.jsf.util.UploadFilter.doFilter(UploadFilter.java:267)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
Merci de m'aider,je vous informe que dans chqcune de mais page j'ouvre la session et je le ferme à la fin de transaction .Et quand je crie un nouveau projet avec la meme structure et la meme configuration tous marche bien.
si vous avez une idée n'hésiter pas .
Partager