voila j travail sur une application avec jsf et hibernate pour une connexion a une base de donnée mysql.
mon probleme c est que quand j invoque ma methode bean depuis mon jsp il me genere cette erreur :
pourtant la meme methode je l invoque depuis le main est ca marche bien
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 ATTENTION: Error calling action method of component with id j_id_jsp_86029888_1:j_id_jsp_86029888_6 javax.faces.FacesException: Error calling action method of component with id j_id_jsp_86029888_1:j_id_jsp_86029888_6 at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:74) at javax.faces.component.UICommand.broadcast(UICommand.java:387) at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:316) at org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:291) at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:248) at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:461) at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100) at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) at java.lang.Thread.run(Unknown Source) Caused by: javax.faces.el.EvaluationException: java.lang.IllegalAccessError at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102) at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63) ... 21 more
voila ma page jsp :
en ce qui concerne mon bean le voila
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 <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Ajouter Certificat</title> </head> <body> <f:view> <h:form> <table width="423" height="71"> <tr> <td width="171" height="21" align="left" valign="top"><strong>Libellé Certificat</strong></td> <td width="3" align="left" valign="top"><strong>:</strong></td> <td align="left" valign="top"> <h:inputText value="#{certificat.libelleCertificat}"/><h:commandButton type="submit" action="#{certificat.submit1}"/> </td> </tr> <tr> <td width="171" height="21" align="left" valign="top"><strong>Abréviation</strong></td> <td width="3" align="left" valign="top"><strong>:</strong></td> <td align="left" valign="top"> <h:inputText value="#{certificat.abreviationCertificat}"/><h:commandButton type="submit" action="#{certificat.submit2}"/> </td> </tr> <tr> <td></td></tr> </table> <h:commandButton type="submit" value="Valider" action="#{certificat.ajouterCertificat}" /> </h:form> </f:view> </body> </html>
pour le hibernateUtil c est une classe a part .
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103 package gima.referentiel.pl; import java.util.HashSet; import java.util.Set; import org.hibernate.Transaction; import org.hibernate.classic.Session; import javax.faces.event.*; public class Certificat { private int idCertificat; private String libelleCertificat; private String abreviationCertificat; private Set Rh = new HashSet(); public Certificat() { } public Certificat(String libelleCertificat, String abreviationCertificat) { this.libelleCertificat=libelleCertificat; this.abreviationCertificat=abreviationCertificat; } public void submit1() { System.out.println(""+getLibelleCertificat()); } public void submit2() { System.out.println(""+getAbreviationCertificat()); } public void submit3() { System.out.println("ajouter"); } public int getIdCertificat() { return idCertificat; } public void setIdCertificat(int idCertificat) { this.idCertificat = idCertificat; } public String getLibelleCertificat() { return libelleCertificat; } public void setLibelleCertificat(String libelleCertificat) { this.libelleCertificat = libelleCertificat; } public String getAbreviationCertificat() { return abreviationCertificat; } public void setAbreviationCertificat(String abreviationCertificat) { this.abreviationCertificat = abreviationCertificat; } public Set<RessourceHumaine> getRh() { return Rh; } public void setRh(Set<RessourceHumaine> rh) { this.Rh = rh; } public void ajouterCertificat() { try { System.out.println("ajouter1"); System.out.println(""+getLibelleCertificat()); System.out.println(""+getAbreviationCertificat()); Session session = (Session) HibernateUtil.currentSession(); System.out.println("ajoutegr"); session.beginTransaction(); Certificat c = new Certificat(); c.setLibelleCertificat(libelleCertificat); c.setAbreviationCertificat(abreviationCertificat); session.save(c); session.getTransaction().commit(); session.close(); } catch( Exception ex) { System.out.println(ex.getMessage()); } } }
la quand j'execute mon application et que je lance le debugage j constate qu'il bug au niveau de la creation de la session hibernate
je comprend vraiment pas pourquoi , svp si quelque pouvais m venir en aide j lui serai reconnaissante
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 Session session = (Session) HibernateUtil.currentSession();
merci d avance
Partager