bonjour,

j'essaie depuis quelques temps de faire fonctionner mon appli sous eclipse.

cela fait plusieurs que j'ai le même problème, et que je n'ai pas réussi à le résoudre.

j'ai mon appli, avec un serveur jboss et hibernate, avec une bas mysql.

j'ai un fichier test.java qui me permet de tester différentes choses avant de les utiliser.

voici un extrait de ce fichier :
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
package com.test;
import java.util.*;
 
import javax.faces.context.FacesContext;
 
import org.hibernate.*;
 
import com.hibernate.*;
 
public class Test {
 
 public static void main(String[] args) throws HibernateException {
 
 Session session = HibernateUtil.currentSession();
 
 Transaction tx= session.beginTransaction();
 
 
 
 String StringList = null;
	// Session Hibernate
 //Session session = HibernateUtil.currentSession();
 List list = session.createQuery("from ForceCommerciale").list();
 System.out.println(list.size());
 
 HibernateUtil.closeSession();
 if (list.size() > 0) 
 {
     Iterator<ForceCommerciale> it = list.iterator();     
    	 ForceCommerciale fc = (ForceCommerciale) it.next();    	 
    	 System.out.println(fc.getNomForceCommerciale());
 }
 
 System.out.println("fin");
 }
 
}
ce test fonctionne PARFAITEMENT.

bien, maintenant, utilisation de tout ça pour se connecter à l'application via un formulaire :

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
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Connexion</title>
</head>
<body>
<c:view>
	<h:form>	
		<h:panelGrid border="1" columns="2">
			<h:outputText value="#{loginBean._mail}"></h:outputText>
			<h:inputText></h:inputText>
			<h:outputText value="#{loginBean._pwd}"></h:outputText>
			<h:inputSecret></h:inputSecret>
		</h:panelGrid>
		<h:commandButton value="Valider" action="#{loginBean.connexion}"></h:commandButton>
	</h:form>
</c:view>
</body>
</html>
le bean :
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
 
// getters et setters
public String connexion() {
		String cnx = "erreur"; 
 
		//ouverture / récupération de la session utilisateur
		FacesContext context = FacesContext.getCurrentInstance();
        HttpSession httpSession = (HttpSession) context.getExternalContext().getSession(false);
 
        // Session Hibernate
        Session session = HibernateUtil.currentSession();
        List list = session.createQuery("from ForceCommerciale f where f.mailForceCommerciale like '" + get_mail() + "' and f.mdpForceCommerciale like '" + get_pwd() + "'").list();
 
        if (list.size() == 0) 
        {
        	cnx = "erreur";
        	httpSession.setAttribute ("statutSession", "invalide");
        }
        else
        {
        	cnx = "connexionOk";
	        Iterator it = list.iterator();
	        ForceCommerciale fc = (ForceCommerciale)it.next();
	        httpSession.setAttribute ("statutSession", "valide");
	        httpSession.setAttribute ("nom", fc.getNomForceCommerciale());
	        httpSession.setAttribute ("prenom", fc.getPrenomForceCommerciale());
	        httpSession.setAttribute ("iduser", fc.getIdForceCommerciale());
        }
 
		return cnx;
	}
}
et 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
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package com.test;
 
import java.util.Properties;
 
import org.apache.log4j.Logger;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
 
public class HibernateUtil
{
    private static final SessionFactory sessionFactory;
    private static final Logger logger = Logger.getLogger(HibernateUtil.class);
 
    static 
    {
        try 
        {
            logger.debug("Création Session Factory Hibernate");
            sessionFactory = new Configuration().configure().buildSessionFactory();
        } 
        catch (HibernateException ex) 
        {
            logger.error("Erreur lors de la création de la Session Factory Hibernate : " + ex.getMessage());
            throw new RuntimeException("Problème de configuration : " + ex.getMessage(), ex);
        }
    }
 
    public static final ThreadLocal session = new ThreadLocal();
 
    /**
     *    Récupération de la session Hibernate
     */
    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) 
        {
            logger.debug("Acquisition d'une nouvelle Session Hibernate pour le Thread " + Thread.currentThread().hashCode());
            s = sessionFactory.openSession();
            session.set(s);
        }
 
        logger.debug("Récupération de la Session Hibernate " + s.hashCode() + " pour le Thread " + Thread.currentThread().hashCode());
        return s;
    }
 
    /**
     *    Fermeture de la session Hibernate
     */
    public static void closeSession() throws HibernateException 
    {
        Session s = (Session) session.get();
        if ( s == null ) return ;
 
        logger.debug("Fermeture de la Session Hibernate " + s.hashCode() + " pour le Thread " + Thread.currentThread().hashCode());
        session.set(null);
        s.close();
    }    
}
--> fonctionne pas !

je ne comprends pas pourquoi, le code est quasiment similaire !

le message d'erreur :
10:52:36,421 INFO [DriverManagerConnectionProvider] using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/test
10:52:36,421 INFO [DriverManagerConnectionProvider] connection properties: {user=root, password=admin}
10:52:36,421 WARN [SettingsFactory] Could not obtain connection metadata
java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost/test


aidez-moi svp, je suis vraiment au bout du rouleau là