IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

JSF Java Discussion :

La méthode du managedBean n'existe pas


Sujet :

JSF Java

  1. #1
    Membre averti
    Femme Profil pro
    Développeur Java
    Inscrit en
    Juillet 2010
    Messages
    48
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Java

    Informations forums :
    Inscription : Juillet 2010
    Messages : 48
    Par défaut La méthode du managedBean n'existe pas
    Salut les amis,Ca fait plus de 2 jours que je galère dans un problème.
    En fait c'est une petite application de test Spring+Hibernate+JSF qui consiste a redirigé vers une page success si l'utilisateur a taper le bon password et login sinn il sera redirigé vers une page d'erreur.

    ATTENTION: #{userMBean.submit}: java.lang.NullPointerException
    javax.faces.FacesException: #{userMBean.submit}: java.lang.NullPointerException
    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)
    at javax.faces.component.UICommand.broadcast(UICommand.java:315)
    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
    at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
    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:859)
    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.NullPointerException
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102)
    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
    ... 19 more
    Caused by: java.lang.NullPointerException
    at com.otv.Bean.UserManageBean.submit(UserManageBean.java:81)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.el.parser.AstValue.invoke(AstValue.java:191)
    at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
    at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
    ... 20 more
    19 juil. 2012 15:01:28 org.apache.catalina.core.StandardContext reload
    INFO: Le rechargement du contexte [/JSF] a démarré
    19 juil. 2012 15:01:28 org.apache.catalina.core.ApplicationContext log
    INFO: Closing Spring root WebApplicationContext
    19 juil. 2012 15:01:28 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
    GRAVE: The web application [/JSF] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
    19 juil. 2012 15:01:28 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
    GRAVE: The web application [/JSF] appears to have started a thread named [Timer-0] but has failed to stop it. This is very likely to create a memory leak.
    19 juil. 2012 15:01:28 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
    GRAVE: The web application [/JSF] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0] but has failed to stop it. This is very likely to create a memory leak.
    19 juil. 2012 15:01:28 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
    GRAVE: The web application [/JSF] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1] but has failed to stop it. This is very likely to create a memory leak.
    19 juil. 2012 15:01:28 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads

  2. #2
    Membre averti
    Femme Profil pro
    Développeur Java
    Inscrit en
    Juillet 2010
    Messages
    48
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Java

    Informations forums :
    Inscription : Juillet 2010
    Messages : 48
    Par défaut
    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
     
    package com.otv.Bean;
     
    import java.io.Serializable;
     
    import com.otv.model.Admin;
    import com.otv.service.AdminService;
     
    public class UserManageBean implements Serializable {
     
    	/**
             * 
             */
    	private static final long serialVersionUID = 1L;
    	private String login;
    	private String password;
    	private String message;
     
    	private AdminService adminService;
     
     
     
    	public String getLogin() {
    		return login;
    	}
    	public void setLogin(String login) {
    		this.login = login;
    	}
    	public AdminService getAdminService() {
    		return adminService;
    	}
    	public String getPassword() {
    		return password;
    	}
    	public void setPassword(String password) {
    		this.password = password;
    	}
     
     
     
    	public void setAdminService(AdminService adminService) {
    		this.adminService = adminService;
    	}
    	public String getMessage() {
    		StringBuffer strBuff=new StringBuffer();
    		strBuff.append(this.getLogin());
    		strBuff.append(this.getPassword());
    		this.setMessage(strBuff.toString());
    		return this.message;
     
    	}
    	public void setMessage(String message) {
    		this.message = message;
    	}
     
    	public void reset()
    	{
    		this.login="";
    		this.password="";
     
    	}
     
    	public String submit()
    	{
    		Admin admin=new Admin();
     
     
     
    		if((adminService.searchLogin(getLogin())!=null) && (adminService.PasswordByLogin(getLogin(), getPassword())))
    		{
    			return "success";
    		}
     
    //		if(getLogin().equals("admin") && getPassword().equals("admin")){
    //		return "success";
    //		
    //		}
    	else
    		{
    			return "error";	
    		}
    		}
     
    	}

    Quand je ne fais aucun appel à adminService dans la méthode submit la méthode est reconnue et ça marche bien !!

  3. #3
    Membre averti
    Femme Profil pro
    Développeur Java
    Inscrit en
    Juillet 2010
    Messages
    48
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Java

    Informations forums :
    Inscription : Juillet 2010
    Messages : 48
    Par défaut
    et voila mon faces-config

    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
     
    <?xml version="1.0" encoding="UTF-8"?>
    <faces-config
        xmlns="http://java.sun.com/xml/ns/javaee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
        http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
        version="2.0">
     
    	<application>
        	<el-resolver>
        		org.springframework.web.jsf.el.SpringBeanFacesELResolver
        	</el-resolver>
      	</application>
     
    	<managed-bean>
    		<managed-bean-name>userMBean</managed-bean-name>
    		<managed-bean-class>com.otv.Bean.UserManageBean</managed-bean-class>
    		<managed-bean-scope>session</managed-bean-scope>
    		<managed-property>
    			<property-name>adminService</property-name>
    			<property-class>com.otv.service.AdminService</property-class>
    			<value>#{adminService}</value>
    		</managed-property>
     
    	</managed-bean>
     
     
     
    	   <navigation-rule>
            <from-view-id>/pages/index.xhtml</from-view-id>
            <navigation-case>
                <from-outcome>success</from-outcome>
                <to-view-id>/pages/welcome.xhtml</to-view-id>
            </navigation-case>
    		     <navigation-case>
                <from-outcome>error</from-outcome>
                <to-view-id>/pages/error.xhtml</to-view-id>
            </navigation-case>
        </navigation-rule>
     
     
     
    </faces-config>

    SVP Aidez moi je ne sais pas d'ou vient le problème

  4. #4
    Membre Expert
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2004
    Messages
    1 184
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Avril 2004
    Messages : 1 184
    Par défaut
    Ta propriété managée #{adminService} n'est pas résolue (Valeur NULL, d'où le NullPointerException). Si c'est censé être fait par SpringBeanFacesELResolver, vérifie que tout est bien configuré de ce côté là.

  5. #5
    Membre averti
    Femme Profil pro
    Développeur Java
    Inscrit en
    Juillet 2010
    Messages
    48
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Java

    Informations forums :
    Inscription : Juillet 2010
    Messages : 48
    Par défaut
    normalement je devrais ajouter dans le fichier pom la dépendance suivante
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
    <dependency>
    <groupId>javax.el</groupId>
    <artifactId>el-api</artifactId>
    <version>2.2</version>
    <scope>provided</scope>
    </dependency>
    mais une fois je l'ajoute c'est une autre exception qui apparait

    when resolving interface method "javax.servlet.jsp.JspApplicationContext.getExpressionFactory()Ljavax/el/ExpressionFactory;" the class loader (instance of org/apache/catalina/loader/WebappClassLoader) of the current class, com/sun/faces/config/ConfigureListener, and the class loader (instance of org/apache/catalina/loader/StandardClassLoader) for resolved class, javax/servlet/jsp/JspApplicationContext, have different Class objects for the type javax/el/ExpressionFactory used in the signature

  6. #6
    Membre Expert
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2004
    Messages
    1 184
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Avril 2004
    Messages : 1 184
    Par défaut
    Ce jar est visiblement déjà dans les libs du serveur. Inutile de l'ajouter à la webapp.

  7. #7
    Membre averti
    Femme Profil pro
    Développeur Java
    Inscrit en
    Juillet 2010
    Messages
    48
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Java

    Informations forums :
    Inscription : Juillet 2010
    Messages : 48
    Par défaut
    oui je viens de constater ça,C'est bon ça marche bien.
    J'ai essayer de démarrer le serveur avec le goal : tomcat:run-war
    de plus même si je déclare le managedbean avec les annotation
    @ManagedBean
    @RequestBean
    Il a fallu que je déclare le tout sur le fichier faces-config.xml ,et les navigation-rules aussi.chose qui m'a paru étrange,normalement ça devrais marché même sans le faces-config puisque je suis en version 2.0
    qu'est ce que vous en pensez ?

  8. #8
    Membre Expert Avatar de jeffray03
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2008
    Messages
    1 501
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Allemagne

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Juillet 2008
    Messages : 1 501
    Par défaut
    pour cela il aurait je crois fallu que:
    1. tu indiques quelque chose comme ceci: @ManagedProperty(value="le nom de la propertie")
    2. @ManagedBean(eager=true) pour le chargement
    3. sans oublier le setter de ta propertie.

    Eric T.

  9. #9
    Membre averti
    Femme Profil pro
    Développeur Java
    Inscrit en
    Juillet 2010
    Messages
    48
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Java

    Informations forums :
    Inscription : Juillet 2010
    Messages : 48
    Par défaut
    Merci. ça marche!!

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 2
    Dernier message: 29/12/2011, 08h45
  2. [Runtime class loading] Appeler une méthode qui n'existe pas
    Par Invité dans le forum Général Java
    Réponses: 14
    Dernier message: 27/06/2008, 08h48
  3. Problème La méthode nommée n'existe pas.
    Par superxou dans le forum ActionScript 1 & ActionScript 2
    Réponses: 7
    Dernier message: 09/06/2008, 22h43
  4. Le membre de collection requis n'existe pas
    Par mschistozis dans le forum Access
    Réponses: 4
    Dernier message: 25/10/2004, 16h41
  5. Réponses: 3
    Dernier message: 24/06/2004, 11h23

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo