Erreur lors de l'envoi de données: javax.el.PropertyNotFoundException
Bonjour
Je débute avec JSF et j'ai commencé par un simple formulaire qui récupére la valeur saisie dans un champ de texte et l'envoie vers une autre page.
Voici le code de la page bonjour.xhtml qui contient le formulaire:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| <!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>Premier exemple JSF 2.0</title>
</h:head>
<h:body>
<h1>Premier exemple JSF 2.0 - bonjour.xhtml</h1>
<h:form>
<h:inputText value="#{bonjourBean.nom}" />
<h:commandButton value="Souhaiter la bienvenue" action="bienvenue" />
</h:form>
</h:body>
</html> |
Et voici la page bienvenue.xhtml censée recevoir la valeur saisie:
Code:
1 2 3 4 5 6 7 8 9 10 11
| <!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>Premier exemple JSF 2.0</title>
</h:head>
<h:body>
<h1>Premier exemple JSF 2.0 - bienvenue.xhtml</h1>
<p>Bienvenue #{bonjourBean.nom} !</p>
</h:body>
</html> |
Voici mon JavaBean:
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
| package org;
import java.io.Serializable;
import javax.inject.Named;
import javax.enterprise.context.RequestScoped;
@Named
@RequestScoped
public class BonjourBean implements Serializable {
private static final long serialVersionUID = 1L;
private String nom;
public String getNom() {
return nom;
}
public void setNom( String nom ) {
this.nom = nom;
}
} |
Et voici mon web.xml:
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 29 30 31
| <?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1">
<display-name>MonProjet</display-name>
<!-- Changer cette valeur à "Production" lors du déploiement final de l'application -->
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<!-- Déclaration du contrôleur central de JSF : la FacesServlet -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Mapping : association des requêtes dont le fichier porte l'extension .xhtml à la FacesServlet -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>bonjour.xhtml</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app> |
Quand je saisis la valeur et que je valide, j'ai le message d'erreur suivant dans le navigateur:
Citation:
An Error Occurred:
/bonjour.xhtml @10,51 value="#{bonjourBean.nom}": Target Unreachable, identifier [bonjourBean] resolved to null
- Stack Trace
javax.el.PropertyNotFoundException: /bonjour.xhtml @10,51 value="#{bonjourBean.nom}": Target Unreachable, identifier [bonjourBean] resolved to null
at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:100)
at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(HtmlBasicInputRenderer.java:95)
at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1046)
at javax.faces.component.UIInput.validate(UIInput.java:976)
at javax.faces.component.UIInput.executeValidate(UIInput.java:1249)
at javax.faces.component.UIInput.processValidators(UIInput.java:712)
at javax.faces.component.UIForm.processValidators(UIForm.java:253)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1261)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1261)
at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1195)
at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
Caused by: javax.el.PropertyNotFoundException: Target Unreachable, identifier [bonjourBean] resolved to null
at org.apache.el.parser.AstValue.getTarget(AstValue.java:74)
at org.apache.el.parser.AstValue.getType(AstValue.java:58)
at org.apache.el.ValueExpressionImpl.getType(ValueExpressionImpl.java:174)
at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:98)
... 35 more
Merci