EvaluationException à l'appel d'un action sur un commandLink
Bonjour,
Je suis en train de développez un intranet en JEE. Je créé la partie login. J'utilise les frameworks hibernate, icefaces et spring.
Je rentre le login et le mot de passe, et quand je clique sur connecter j'ai une exception :
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
28 mai 2009 11:12:56 com.sun.faces.application.ActionListenerImpl processAction
GRAVE: java.lang.NullPointerException
javax.faces.el.EvaluationException: java.lang.NullPointerException
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
at javax.faces.component.UICommand.broadcast(UICommand.java:387)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:475)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:756)
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 com.icesoft.faces.webapp.http.core.JsfLifecycleExecutor.apply(JsfLifecycleExecutor.java:16)
at com.icesoft.faces.webapp.http.core.ReceiveSendUpdates.renderCycle(ReceiveSendUpdates.java:114)
at com.icesoft.faces.webapp.http.core.ReceiveSendUpdates.service(ReceiveSendUpdates.java:66)
at com.icesoft.faces.webapp.http.core.RequestVerifier.service(RequestVerifier.java:26)
at com.icesoft.faces.webapp.http.common.standard.PathDispatcherServer.service(PathDispatcherServer.java:24)
at com.icesoft.faces.webapp.http.servlet.MainSessionBoundServlet.service(MainSessionBoundServlet.java:160)
at com.icesoft.faces.webapp.http.servlet.SessionDispatcher$1.service(SessionDispatcher.java:30)
at com.icesoft.faces.webapp.http.servlet.ThreadBlockingAdaptingServlet.service(ThreadBlockingAdaptingServlet.java:19)
at com.icesoft.faces.webapp.http.servlet.EnvironmentAdaptingServlet.service(EnvironmentAdaptingServlet.java:63)
at com.icesoft.faces.webapp.http.servlet.SessionDispatcher.service(SessionDispatcher.java:50)
at com.icesoft.faces.webapp.http.servlet.SessionVerifier.service(SessionVerifier.java:22)
at com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:23)
at com.icesoft.faces.webapp.http.servlet.MainServlet.service(MainServlet.java:155)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at com.icesoft.faces.webapp.xmlhttp.BlockingServlet.service(BlockingServlet.java:56)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
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: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: java.lang.NullPointerException
at web.pages.identification.Identification.authentifier(Identification.java:41)
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 org.apache.el.parser.AstValue.invoke(AstValue.java:172)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88) |
Je vous explique comment c'est codé maintenant.
Dans ma page web "identification.jspx" j'appelle la méthode authentifier du bean login :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
<ice:form id="formConnecter">
<ice:panelGrid columns="2" styleClass="login">
<ice:outputLabel value="Login :" for="login" styleClass="textBleu"></ice:outputLabel>
<ice:inputText id="login" value="#{login.login}" styleClass="inputTextIdentification"></ice:inputText>
<ice:outputLabel value="Mot de passe :" for="motDePasse" styleClass="textBleu"></ice:outputLabel>
<ice:inputSecret id="motDePasse" value="#{login.password}" styleClass="inputTextIdentification"></ice:inputSecret>
</ice:panelGrid>
<ice:panelGroup styleClass="cadreBoutonConnecter">
<ice:commandLink id="boutonConnecter" styleClass="bouonConnecter" value="Connecter" action="#{login.authentifier}"></ice:commandLink>
</ice:panelGroup>
</ice:form> |
Voilà le code du bean login :
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 32 33
|
public class Identification {
//login de l'utilisateur
private String login;
//mot de passe de l'utilisateur
private String password;
//vrai si l'utilisateur s'est trompé lors de la saisie du login et du mot de passe. faux sinon
private boolean erreur;
//service pour la connection
private IUtilisateursManager serviceUtilisateur;
/**
* identifie l'utilisateur qui veut se connecter et le redirige vers la page d'accueil si les identifiants
* sont corrects ou vers la page de login
* @return la page de rediredtion
*/
public String authentifier(){
//TODO: terminer l'appel à la couche service pour récupérer l'utilisateur
String url; //page sur laquelle doit être redirigé l'utilisateur
if(this.serviceUtilisateur.verifierLogin(this.login, this.password)){
this.erreur = false;
url = "accueil";
}
else {
this.erreur = true;
url = "erreur";
}
return url;
}
// des getteurs et setteurs pour chaque attributs |
Dans la méthode authentifier, j'appelle verifierLogin de la couche service, qui appelle verifierLogin de la couche DAO.
J'ai ajouté les beans nécessaires dans le fichier faces-config.xml et applicationContext.xml.
Le bean login dans faces-config.xml :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
<managed-bean>
<description> Ce bean permet de traiter l'identification d'un utilisateur pour accéder à l'intranet. </description>
<managed-bean-name>login</managed-bean-name>
<managed-bean-class>
web.pages.identification.Identification
</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-property>
<property-name> serviceUtilisateur </property-name>
<value> #{service.IUtilisateursManager} </value>
</managed-property>
</managed-bean> |
Le fichier appplicationContext.xml :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
<beans>
<bean id="UtilisateursManagerTarget" class=" service.impl.UtilisateursManagerImpl">
<property name="utilisateursDao">
<ref bean="utilisateursDao" />
</property>
</bean>
<bean id="utilisateursManager" parent="transactionProxy">
<property name="transactionManager">
<ref bean="transactionManager"/> <!-- bean du applicationContextDao.xml -->
</property>
<property name="target">
<ref bean="UtilisateursManagerTarget"/>
</property>
<property name="transactionAttributeSource">
<bean class="org.springframework.transaction.annotation.AnnotationTransactionAttributeSource"/>
</property>
</bean>
</beans> |
Je pense qu'il n'y a pas d'injection du bean utilisateursManager dans le bean login (= Identification.java).
En vous remerciant d'avance,
Nicolas