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 NullPointerException


Sujet :

JSF Java

  1. #1
    Membre éclairé 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
    Par défaut Erreur NullPointerException
    salut
    D'après ce que je comprends java.lang.NullPointerException veut dire qu'il ya quelque chose qui est nulle alors qu'elle ne dois pas l'etre, c'est ça?
    je travaille avec eclipse JEE application web, je suis encore débutante et j'ai eu cette erreur en appliquant un exemple de tutoriel:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    Grave: Servlet.service() for servlet [jsp] in context with path [/TutorielJSF2] threw exception [java.lang.NullPointerException] with root cause
    java.lang.NullPointerException
    	at javax.faces.webapp.UIComponentClassicTagBase.setJspId(UIComponentClassicTagBase.java:1858)
    	at org.apache.jsp.Ajouter_jsp._jspx_meth_h_005fform_005f0(Ajouter_jsp.java:121)
    	at org.apache.jsp.Ajouter_jsp._jspService(Ajouter_jsp.java:93)
    le code de Ajouter.jsp est:
    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" %>
     
        <!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>
    et voila le code correspondant au mapping du bean personne (un bean contenant les champs de la table personne à la base de donnée)
    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
    <?xml version="1.0" encoding="UTF-8"?>
     
    <!DOCTYPE hibernate-mapping PUBLIC
            "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
     
            "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
     
            <hibernate-mapping>
            <class name="beans.Personne" table="PERSONNE">
            <id name="id_personne" type="java.lang.Integer" column="id_personne">
                     <generator class="increment"/>
            </id>
            <property name="nom" type="java.lang.String">
            <column name="nom"/>
            </property>
            <property name="prenom" type="java.lang.String">
            <column name="prenom"/>
            </property>
            <property name="age" type="java.lang.Integer">
            <column name="age"/>
            </property>
            <property name="date_naissance" type="java.util.Date">
            <column name="date_naissance"/>
            </property>
     
            </class>
            </hibernate-mapping>
    Merci pour votre aide

  2. #2
    Expert éminent
    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 : 46
    Localisation : Belgique

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

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 482
    Par défaut
    Tu pourrais nous donner le message complet (avec les root cause etc)? Parce que là il est vachement coupé
    Tu passe bien par la servlet JSF (en gros tu n'essaie pas d'afficher directement la jsp n'est-ce pas?)

  3. #3
    Membre éclairé 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
    Par défaut
    Citation Envoyé par tchize_ Voir le message
    Tu pourrais nous donner le message complet (avec les root cause etc)? Parce que là il est vachement coupé
    Tu passe bien par la servlet JSF (en gros tu n'essaie pas d'afficher directement la jsp n'est-ce pas?)
    effectivement j'accède directement à la page ajouter.jsp (c'est faux?) qui devra m'afficher à formulaire à remplir mais le problème c'est que d'habitude avec "jsp" j'écris toute seule la page servlet correspondante mais avec jsf servlet est généré automatiquement..
    voilà le code d'erreur complet:
    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
    août 13, 2012 9:05:54 PM org.apache.catalina.core.StandardWrapperValve invoke
    Grave: Servlet.service() for servlet [jsp] in context with path [/TutorielJSF2] threw exception [java.lang.NullPointerException] with root cause
    java.lang.NullPointerException
    	at javax.faces.webapp.UIComponentClassicTagBase.setJspId(UIComponentClassicTagBase.java:1858)
    	at org.apache.jsp.Ajouter_jsp._jspx_meth_h_005fform_005f0(Ajouter_jsp.java:121)
    	at org.apache.jsp.Ajouter_jsp._jspService(Ajouter_jsp.java:93)
    	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
    	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
    	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1001)
    	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
    	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    	at java.lang.Thread.run(Unknown Source)

  4. #4
    Expert éminent
    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 : 46
    Localisation : Belgique

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

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 482
    Par défaut
    Tu dois toujours passer par la servlet JSF. Regarde quel mapping tu as configuré pour cette servlet et pointe ton browser vers cette servlet plutot que vers ta page jsp. En général on mappe la servlet vers faces/* ou ver *.jsf.

    Dans le premier cas, il suffira de rajouter faces/ au début de l'url de ta page, dans le second de remplacer le .jsp par un .jsf.

    Pour plus d'info, regardez dans les documentations de jsf, c'est décrit partout.

  5. #5
    Membre éclairé 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
    Par défaut
    Pièce jointe 100708j'utilise
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    <servlet-mapping>
      <servlet-name>Faces Servlet</servlet-name>
      <url-pattern>*.faces</url-pattern>
      </servlet-mapping>
    donc normalement je fais /faces/Ajouter.jsp mais voilà que ça ne fonctionne pas aussi :\

    La ressource demandée (/TutorielJSF2/faces/Ajouter.jsp) n'est pas disponible.

    Ne manque-t-il pas un .jar quelques par? voilà je mets une capture de ce que contient /WEB-INF/lib
    Images attachées Images attachées  

  6. #6
    Expert éminent
    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 : 46
    Localisation : Belgique

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

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 482
    Par défaut
    non, c'est *.faces donc Ajouter.faces

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

Discussions similaires

  1. une erreur nullPointerException
    Par artemis93 dans le forum Débuter avec Java
    Réponses: 3
    Dernier message: 11/05/2011, 13h28
  2. Erreur NullPointerException
    Par simaing dans le forum Général Java
    Réponses: 7
    Dernier message: 01/05/2008, 20h00
  3. erreur NullPointerException à l'éxécution
    Par rcober dans le forum Débuter avec Java
    Réponses: 4
    Dernier message: 13/03/2008, 10h05
  4. Erreur NullPointerException - Hibernate
    Par elloyeen dans le forum Struts 1
    Réponses: 4
    Dernier message: 30/12/2007, 03h20
  5. Réponses: 3
    Dernier message: 25/04/2007, 14h22

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