j'ai crée une page jsp pour l'authentification :
Le bean associé est le suivant :
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 <h:form> <h:panelGrid columns="2" style="background-color: #FF8000"> <h:outputText value="Login :"></h:outputText><h:inputText value="#{identifyUser.log}"></h:inputText> <h:outputText value="Mot de passe:"></h:outputText><h:inputSecret value="#{identifyUser.passw}"></h:inputSecret> </h:panelGrid> <h:commandButton value="Se Connecter " action="#{identifyUser.verifier}"></h:commandButton><br/><br/> <h:outputText id="mess" value="#{identifyUser.mes}" style="color: #FF0000; font-size: 30px"></h:outputText> </center> </h:form>
la classe utilisteur generé par Hibernate est la suivante :
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
64
65
66
67
68
69
70
71
72
73
74
75
76 package bean; import java.util.Iterator; import org.hibernate.Query; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; import stt.Utilisateur; public class IdentifyUser { private String log; private String passw; private String mes; public String getLog() { return log; } public void setLog(String log) { this.log = log; } public String getPassw() { return passw; } public void setPassw(String passw) { this.passw = passw; } public String verifier() { boolean verif=false; SessionFactory sessionfactory = new Configuration().configure().buildSessionFactory(); Session session = sessionfactory.openSession(); try { Query q = session.createQuery("from Utilisateur"); Iterator it = q.iterate(); while (it.hasNext()) { Utilisateur u = (Utilisateur)it.next(); if ((u.getId().contains(this.log))&& (u.getPassword().contains(passw))) { verif=true; } } } finally { session.close(); } sessionfactory.close(); if (verif==true) { mes=""; return "ok"; } else { mes ="Votre Login ou votre mot de passe est incorrecte veuillez verifier"; return "nok"; } } public void setMes(String mes) { this.mes = mes; } public String getMes() { return mes; } }
lorsque j'essaie de se connecter une exception se declanche :
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 package stt; import stt.base.BaseUtilisateur; public class Utilisateur extends BaseUtilisateur { private static final long serialVersionUID = 1L; /*[CONSTRUCTOR MARKER BEGIN]*/ public Utilisateur () { super(); } /** * Constructor for primary key */ public Utilisateur (java.lang.String id) { super(id); } /** * Constructor for required fields */ public Utilisateur ( java.lang.String id, java.lang.String password, java.lang.Integer matricule, java.lang.Integer profile) { super ( id, password, matricule, profile); } /*[CONSTRUCTOR MARKER END]*/
mes regles de navigation sont bien déclaré dans le facesconfig et j'ai pas pu identifier le probleme et voila les regles de navigation :
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86 exception javax.servlet.ServletException: Error calling action method of component with id j_id_jsp_694048630_2:j_id_jsp_694048630_8 javax.faces.webapp.FacesServlet.service(FacesServlet.java:256) cause m�re javax.faces.FacesException: Error calling action method of component with id j_id_jsp_694048630_2:j_id_jsp_694048630_8 org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:72) javax.faces.component.UICommand.broadcast(UICommand.java:383) 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) javax.faces.webapp.FacesServlet.service(FacesServlet.java:244) cause m�re javax.faces.el.EvaluationException: org.hibernate.MappingException: could not instantiate id generator [entity-name=stt.Utilisateur] javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:91) org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:57) javax.faces.component.UICommand.broadcast(UICommand.java:383) 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) javax.faces.webapp.FacesServlet.service(FacesServlet.java:244) cause m�re org.hibernate.MappingException: could not instantiate id generator [entity-name=stt.Utilisateur] org.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:132) org.hibernate.mapping.SimpleValue.createIdentifierGenerator(SimpleValue.java:175) org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:224) org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1327) bean.IdentifyUser.verifier(IdentifyUser.java:35) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) java.lang.reflect.Method.invoke(Method.java:585) org.apache.el.parser.AstValue.invoke(AstValue.java:172) org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276) org.apache.jasper.el.JspMethodExpression.invoke(JspMethodExpression.java:68) javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:77) org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:57) javax.faces.component.UICommand.broadcast(UICommand.java:383) 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) javax.faces.webapp.FacesServlet.service(FacesServlet.java:244) cause m�re org.hibernate.MappingException: Dialect does not support sequences org.hibernate.dialect.Dialect.getSequenceNextValString(Dialect.java:619) org.hibernate.id.SequenceGenerator.configure(SequenceGenerator.java:88) org.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:127) org.hibernate.mapping.SimpleValue.createIdentifierGenerator(SimpleValue.java:175) org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:224) org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1327) bean.IdentifyUser.verifier(IdentifyUser.java:35) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) java.lang.reflect.Method.invoke(Method.java:585) org.apache.el.parser.AstValue.invoke(AstValue.java:172) org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276) org.apache.jasper.el.JspMethodExpression.invoke(JspMethodExpression.java:68) javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:77) org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:57) javax.faces.component.UICommand.broadcast(UICommand.java:383) 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) javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
quelle rectification ouis je ajouter ?
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 <navigation-rule> <display-name>Identify</display-name> <from-view-id>/Identify.jsp</from-view-id> <navigation-case> <from-outcome>ok</from-outcome> <to-view-id>/Acceuil.jsp</to-view-id> </navigation-case> </navigation-rule> <navigation-rule> <display-name>Identify</display-name> <from-view-id>/Identify.jsp</from-view-id> <navigation-case> <from-outcome>nok</from-outcome> <to-view-id>/Identify.jsp</to-view-id> </navigation-case> </navigation-rule>
merci pour votre aide
Partager