Bonjour à tous,
Je débute en programmation EJB et j'ai actuellement un ptit projet en cours. Il s'agit d'un helpdesk tout simple permettant aux utilisateurs de mon entreprise de poster des tickets en cas de soucis.
J'ai créé 2 classes (1 classe Poster et 1 classe Ticket). Pour le moment, je n'utilise que la classe Poster. En effet, je suis en train de créer le formulaire d'enregistrement permettant aux utilisateurs de s'enregistrer sur le site afin qu'ils puissent déposer des tickets par la suite.
Je développe sous Netbeans 6.5 et j'utilise glassfish comme serveur d'application. Mon problème vient du fait que je n'arrive pas à persister mon utilisateur (poster) en BDD. Le serveur me dit que ma propriété "login" n'existe pas dans mon bean.
Code la classe Poster:
Code du session bean généré à partir de mon entity Bean (Poster):
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119 /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package com.alefpa.entity; import java.io.Serializable; import java.util.List; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.OneToMany; /** * * @author Thierry */ @Entity public class Poster implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; private String login; private String password; private String email; private String last_name; private String first_name; @OneToMany(mappedBy = "poster") private List<Ticket> list_tickets; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getFirst_name() { return first_name; } public void setFirst_name(String first_name) { this.first_name = first_name; } public String getLast_name() { return last_name; } public void setLast_name(String last_name) { this.last_name = last_name; } public List<Ticket> getList_tickets() { return list_tickets; } public void setList_tickets(List<Ticket> list_tickets) { this.list_tickets = list_tickets; } public String getLogin() { return login; } public void setLogin(String login) { this.login = login; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } @Override public int hashCode() { int hash = 0; hash += (id != null ? id.hashCode() : 0); return hash; } @Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof Poster)) { return false; } Poster other = (Poster) object; if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) { return false; } return true; } @Override public String toString() { return "com.alefpa.entity.Poster[id=" + id + "]"; } }
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 /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package com.alefpa.session; import com.alefpa.entity.Poster; import java.util.List; import javax.ejb.Stateless; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; /** * * @author Thierry */ @Stateless public class PosterFacade implements PosterFacadeLocal { @PersistenceContext(name="SupportGR-ejbPU") private EntityManager em; public void create(Poster poster) { em.persist(poster); } public void edit(Poster poster) { em.merge(poster); } public void remove(Poster poster) { em.remove(em.merge(poster)); } public Poster find(Object id) { return em.find(Poster.class, id); } public List<Poster> findAll() { return em.createQuery("select object(o) from Poster as o").getResultList(); } }
Code du 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 <?xml version='1.0' encoding='UTF-8'?> <!-- =========== FULL CONFIGURATION FILE ================================== --> <faces-config version="1.2" 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_1_2.xsd"> <managed-bean> <managed-bean-name>posterBean</managed-bean-name> <managed-bean-class>com.alefpa.session.PosterFacade</managed-bean-class> <managed-bean-scope>application</managed-bean-scope> </managed-bean> </faces-config>
Code du web.xml:
Erreur généré:
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 <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" 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-app_2_5.xsd"> <context-param> <param-name>com.sun.faces.verifyObjects</param-name> <param-value>false</param-value> </context-param> <context-param> <param-name>com.sun.faces.validateXml</param-name> <param-value>true</param-value> </context-param> <context-param> <param-name>javax.faces.STATE_SAVING_METHOD</param-name> <param-value>client</param-value> </context-param> <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>/faces/*</url-pattern> </servlet-mapping> <session-config> <session-timeout> 30 </session-timeout> </session-config> <welcome-file-list> <welcome-file>faces/index.jsp</welcome-file> </welcome-file-list> </web-app>
Si quelqu'un aurait une petite idée du souci, cela m'aiderait bcp !!!! merci d'avance !!
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 État HTTP 500 - type Rapport d'exception Message DescriptionLe serveur a rencontré une erreur interne () qui l'a empêché de remplir cette requête. Exception javax.servlet.ServletException: La classe 'com.alefpa.session.PosterFacade' ne possède pas la propriété 'login'. Cause racine javax.el.PropertyNotFoundException: La classe 'com.alefpa.session.PosterFacade' ne possède pas la propriété 'login'. note Les suivis de pile complets de l'exception et de ses causes principales sont disponibles dans les journaux Sun Java System Application Server 9.1_02.![]()
Partager