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 :

Erreur "Target Unreachable, identifier 'bean' resolved to null"


Sujet :

JSF Java

  1. #1
    Membre actif Avatar de janyoura
    Femme Profil pro
    étudiante ingénierie informatique
    Inscrit en
    Mars 2012
    Messages
    365
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : étudiante ingénierie informatique

    Informations forums :
    Inscription : Mars 2012
    Messages : 365
    Points : 279
    Points
    279
    Par défaut Erreur "Target Unreachable, identifier 'bean' resolved to null"
    salut
    j'ai un problème avec l'identfication d'un bean. je travaille sur un projet web dynamique sous eclipse.
    c'est qu'il n'a pas été créé mais je ne comprends pas la cause!
    merci pour votre aide

    faces-config.xml
    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
    <?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">
    	<managed-bean>
    		<managed-bean-name>bean</managed-bean-name>
    		<managed-bean-class>beans.Personne</managed-bean-class>
    		<managed-bean-scope>session</managed-bean-scope>
    	</managed-bean>
     
    	<navigation-rule>
      <from-view-id>Ajouter.jsp</from-view-id>
      <navigation-case>
       <from-outcome>success</from-outcome>
       <to-view-id>Confirmer.jsp</to-view-id>
      </navigation-case>
    		</navigation-rule>
     
    </faces-config>
    WebContent/Ajouter.jsp
    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
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
        pageEncoding="ISO-8859-1"%>
        <%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
        <%@taglib uri="http://java.sun.com/jsf/core" prefix="c" %>
        <%@taglib uri="http://richfaces.org/rich" prefix="rich" %>
        <%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
        <!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>Ajouter</title>
    <style type="text/css">
    .style1 {
    border:1px solid black;
    }
    </style>
    </head>
    <body>
    <f:view>
    <h:form>
    <table style="width: 68%" class="style1">
    <tr>
    <td style="width: 147px">Nom</td>
    <td style="width: 23px">:</td>
    <td colspan="2">
    <h:inputText id="nom" value="#{bean.nom}" style="width: 244px"/>
    </td>
    </tr>
    <tr>
    <td style="width: 147px">Prenom</td>
    <td style="width: 23px">:</td>
    <td colspan="2"><h:inputText id="prenom" value="#{bean.prenom}" style="width: 244px" />
    </td>
    </tr>
    <tr>
    <td style="width: 147px">Age </td>
    <td style="width: 23px">:</td>
    <td colspan="2"><h:inputText id="age" value="#{bean.age}" style="width: 244px"/></td>
    </tr>
    <tr>
    <td style="width: 147px">Date de naissance</td>
    <td style="width: 23px">:</td>
    <td colspan="2">
    <rich:calendar value="#{bean.date_naissance }" required="false" cellWidth="18px" cellHeight="16px" datePattern="MMM d,yyyy"/>
    </td>
    </tr>
    <tr>
    <td style="width: 147px"></td>
    <td style="width: 23px"></td>
    <td style="width: 271px"></td>
    <td><h:commandButton action="#{bean.AjouterPersonne }" value="Ajouter"/></td>
    </tr>
     
    </table>
    </h:form>
    </f:view>
    </body>
    </html>
    Personne.java
    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
    package beans;
     
    import java.util.Date;
     
     
    import org.hibernate.classic.Session;
     
    import util.HibernateUtil;
     
    public class Personne {
    	private int id_personne;
    	private String nom;
    	private String prenom;
    	private int age;
    	private Date date_naissance;
     
    	public int getId_personne() {
    		return id_personne;
    	}
     
    	public void setId_personne(int id_personne) {
    		this.id_personne = id_personne;
    	}
     
    	public String getNom() {
    		return nom;
    	}
     
    	public void setNom(String nom) {
    		this.nom = nom;
    	}
     
    	public String getPrenom() {
    		return prenom;
    	}
     
    	public void setPrenom(String prenom) {
    		this.prenom = prenom;
    	}
     
    	public int getAge() {
    		return age;
    	}
     
    	public void setAge(int age) {
    		this.age = age;
    	}
     
    	public Date getDate_naissance() {
    		return date_naissance;
    	}
     
    	public void setDate_naissance(Date date_naissance) {
    		this.date_naissance = date_naissance;
    	}
     
    	public String AjouterPersonne() {
    		Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    		session.beginTransaction();
    		Personne p = new Personne();
    		p.setNom(this.nom);
    		p.setPrenom(this.prenom);
    		p.setAge(this.age);
    		p.setDate_naissance(this.date_naissance);
    		session.save(p);
    		session.getTransaction().commit();
    		return "success";
    	}
     
    }
    erreur:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    Grave: Servlet.service() for servlet [Faces Servlet] in context with path [/TutorielJSF2] threw exception [/Ajouter.jsp(26,0) '#{bean.nom}' Target Unreachable, identifier 'bean' resolved to null] with root cause
    org.apache.jasper.el.JspPropertyNotFoundException: /Ajouter.jsp(26,0) '#{bean.nom}' Target Unreachable, identifier 'bean' resolved to null
    	at org.apache.jasper.el.JspValueExpression.getType(JspValueExpression.java:63)
    	at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(HtmlBasicInputRenderer.java:95)
    	at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1030)
    	at javax.faces.component.UIInput.validate(UIInput.java:960)

  2. #2
    Expert éminent sénior
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 482
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 482
    Points : 48 807
    Points
    48 807
    Par défaut
    regarde les logs qui précèdent, il doit surement être écrit par jsf pourquoi le bean n'a pas pu être instancié. Si aucun message, c'est que ton face-config n'est pas au bon endroit et n'est donc pas lu

  3. #3
    Membre actif Avatar de janyoura
    Femme Profil pro
    étudiante ingénierie informatique
    Inscrit en
    Mars 2012
    Messages
    365
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : étudiante ingénierie informatique

    Informations forums :
    Inscription : Mars 2012
    Messages : 365
    Points : 279
    Points
    279
    Par défaut
    Désolée je n'ai pas compris. Faces-config est sous /WEBCONTENT dc emplacement correcte normalement

  4. #4
    Membre actif Avatar de janyoura
    Femme Profil pro
    étudiante ingénierie informatique
    Inscrit en
    Mars 2012
    Messages
    365
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : étudiante ingénierie informatique

    Informations forums :
    Inscription : Mars 2012
    Messages : 365
    Points : 279
    Points
    279
    Par défaut
    Ah ça va c'est résolu j'ai mis faces-config.xml sous webcontent alors qu'au fichier web.xml j'ai déclaré qu'il est sous /web-inf. Dire que j'ai passé tout le jour cherchant la cause. quelle bétise!
    merci

  5. #5
    Membre averti
    Homme Profil pro
    Inscrit en
    Mai 2011
    Messages
    790
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tunisie

    Informations forums :
    Inscription : Mai 2011
    Messages : 790
    Points : 443
    Points
    443
    Par défaut
    une petite remarque essaye de mettre le nom du bean significative car ça peut te poser des probléme lorsque vous etes entrain de developper une application

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

Discussions similaires

  1. Réponses: 3
    Dernier message: 26/01/2015, 09h00
  2. Réponses: 0
    Dernier message: 21/11/2014, 17h00
  3. Erreur "Target Unreachable, identifier 'helloWorld' resolved to null"
    Par thierryler dans le forum Frameworks Web
    Réponses: 5
    Dernier message: 30/08/2011, 11h52
  4. Réponses: 7
    Dernier message: 25/05/2011, 19h07
  5. Réponses: 1
    Dernier message: 29/09/2010, 16h15

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