Bonjour,
je développe une application web avec jsf et hibernate, tout était bien et l'interface s'affiche mais quand j'ai fermé l'ordinateur et puis le redémarrer cette erreur s'affiche:
javax.servlet.ServletException: Could not initialize class model.Hibernateutil
javax.faces.webapp.FacesServlet.service(FacesServlet.java:606)
est ce que quelqu'un peut m'aider?
voici le code du hibernate.cfg.xml:
hibernateutil:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 <?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 name=""> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernate.connection.url">jdbc:mysql://127.0.0.1:3306/gestion_charges_personnelles</property> <property name="hibernate.connection.username">root</property> <property name="hibernate.connection.password"></property> <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> <property name="hibernate.current_session_context_class">thread</property> <property name="hibernate.connection.pool_size">1</property> <mapping class="entities.Profil"/> </session-factory> </hibernate-configuration>
et le managedbean:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 package model; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; public class Hibernateutil { public static final SessionFactory sessionFactory; static { try { // Création de la SessionFactory à partir de hibernate.cfg.xml sessionFactory = new Configuration().configure("Hibernate.cfg.xml").buildSessionFactory(); } catch (Throwable ex) { // Make sure you log the exception, as it might be swallowed System.err.println("Initial SessionFactory creation failed." + ex); throw new ExceptionInInitializerError(ex); } } // public static final ThreadLocal session = new ThreadLocal(); public static SessionFactory getSessionFactory() { return sessionFactory; } }
Merci
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41 package controller; import javax.faces.bean.ManagedBean; import javax.faces.bean.SessionScoped; import model.ProfilModel; import entities.Profil; @ManagedBean(name= "control") @SessionScoped public class ProfilController { private ProfilModel profilmodel= new ProfilModel(); private Profil profil = new Profil(); private String message; public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } public Profil getProfil() { return profil; } public void setProfil(Profil profil) { this.profil = profil; } public String login (){ if (profilmodel.login(this.profil.getLogin(), this.profil.getMdp())!= null) return "welcome"; else { this.message="compte invalide"; this.profil= new Profil (); return "login"; } } }
Partager