Problème lors de l'insertion des valeurs d'un formulaire dans une base
Bonjour,
Cette erreur me rend folle , qui peut m'aider, s'il vous plait :roll:
Formulaire :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| <p:panelGrid columns="2" >
<h:outputText value="Matricule:" />
<h:inputText value="#{xResponsable.mat}" />
<h:outputText value="Nom:" />
<h:inputText value="#{xResponsable.nom}" />
<h:outputText value="Prenom:" />
<h:inputText value="#{xResponsable.prenom}" />
<h:outputText value="Login:" />
<h:inputText value="#{xResponsable.login}" />
<h:outputText value="Mot de passe :" />
<p:password value="#{xResponsable.pass}" />
<h:commandButton value="Ajouter" actionListener="#{xResponsable.ajout()}"/>
</p:panelGrid> |
La méthode ajout :
Code:
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
| public String ajout()throws Exception{
Session session= HibernateUtil.buildSessionFactory();
Transaction TR=null;
try{
TR = session.beginTransaction() ;
Responsable resp = new Responsable(mat,nom,prenom,Login,Pass);
session.save(resp);
session.flush();
TR.commit();
}
catch (Exception e) {
if (TR != null) {
try {
TR.rollback();
} catch (HibernateException he) {
throw he;
}}
throw e;
}finally {
try {
session.close();} catch (HibernateException ex) {
throw new Exception(ex);
}}
return "acceuil" ;
} |
Erreur :
java.lang.ExceptionInInitializerError
at HibernateUtil.buildSessionFactory(HibernateUtil.java:26)
at XResponsable.ajout(XResponsable.java:34)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.apache.el.parser.AstValue.invoke(AstValue.java:261)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:277)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:147)
at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)........
Merci d'avance pour votre aide.