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:
le code de Ajouter.jsp est:
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)
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
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>
Merci pour votre aide
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>
Partager