Bonjour à tous;
mon pb 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
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
 
 
12563 [http-8080-2] INFO  dao.FormationDao  - *********
12563 [http-8080-2] ERROR com.sun.faces.lifecycle.InvokeApplicationPhase  - #{formationdao.update}: javax.faces.el.EvaluationException: java.lang.NullPointerException
javax.faces.FacesException: #{formationdao.update}: javax.faces.el.EvaluationException: java.lang.NullPointerException
	at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:78)
	at javax.faces.component.UICommand.broadcast(UICommand.java:312)
	at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:267)
	at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:381)
	at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:75)
	at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
	at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
	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.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
	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:286)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
	at java.lang.Thread.run(Thread.java:619)
Caused by: javax.faces.el.EvaluationException: java.lang.NullPointerException
	at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:130)
	at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:72)
	... 20 more
Caused by: java.lang.NullPointerException
	at dao.FormationDao.update(FormationDao.java:59)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:126)
	... 21 more
En faite, voici la page editFormation.JSP ou j'ai appelé la méthode update

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
 
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="html"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="core"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!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>Modification d'une formation</title>
</head>
<body>
<br>
<center>
<h2>Modifier une Formation</h2>
<br>
<core:view>
<html:form>	
		<html:outputLabel value="Le sujet de la formation: "></html:outputLabel>
		<html:inputText value="#{formationctrl.selectedFormation.sujet}" />
		<br>
		<br>
		<html:outputLabel value="La date de la formation: "></html:outputLabel>
		<html:inputText value="#{formationctrl.selectedFormation.date}"></html:inputText>
		<br>
		<br>
 
		<html:outputLabel value="La durée de la formation: "></html:outputLabel>
		<html:inputText value="#{formationctrl.selectedFormation.duree}" />
		<br>
		<br>
 
		<html:outputLabel value="La formation sera assurée par: " />
		<html:inputText value="#{formationctrl.selectedFormation.formateur}" />
		<br>
		<br>
	<html:commandButton value="Enregistrer" action="#{formationdao.update}"></html:commandButton>
 
</html:form>	
 
	<html:outputLink value="listformations"></html:outputLink>
</core:view></center>
</body>
</html>
et voici le code de la méthode update()
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
 
package dao;
import java.util.Iterator;
import java.util.List;
import javax.faces.context.FacesContext;
import org.apache.log4j.Logger;
import org.hibernate.Session;
import org.hibernate.Transaction;
import dto.Formation;
 
public class FormationDao {
	Logger log = Logger.getLogger(this.getClass().getName());
 
	public String update(){
 
		String S = "accepted";
		Session session = null;
		Formation format=new Formation();
		format=(Formation) FacesContext.getCurrentInstance()
		.getExternalContext().getSessionMap().get("formation");
		log.info("*********");
		if(format.getFormateur()=="")
			{return"rejected";}
		else 
		{	
		session = HibernateSessionFactory.currentSession();
		Transaction tx = session.beginTransaction();
		log.info(format.getSujet()+""+format.getFormateur()+""+format.getDate());
		session.update(format);
		tx.commit();
		return S;
		}
		}
}
RQE: pratiquement le code de update est le même du code de insertion qui fonctionne correctement.

Best Regards & cordialement.