Salut à tous,
Je suis confronté à un problème insoluble pour mon niveau d'expérience vu que je débute pour apprendre spring et hibernante.
J'ai l'erreur précitée dans le titre et pourtant j'ai bien spring-orm dans mon classpath![]()
Je joins une capture d'écran de mes lib dans mon classpath.
ici ma classe User:
Mon context.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
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210 package modele.DAO.beans.user; import java.text.SimpleDateFormat; import java.util.Date; /*import javax.validation.constraints.Pattern; import javax.validation.constraints.Max; import javax.validation.constraints.Min; import javax.validation.constraints.Size;*/ import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.Table; /** * User generated by hbm2java */ @Entity @Table(name = "user") public class User implements java.io.Serializable { @Id @Column(name = "user_id") @GeneratedValue private Integer userId; //@Size(min = 1, message="trou dcul c'est faux") @Column(name = "user_login") private String userLogin; @Column(name = "user_pswd") private String userPswd; @Column(name = "user_nom") private String userNom; @Column(name = "user_prenom") private String userPrenom; @Column(name = "user_adresse") private String userAdresse; @Column(name = "user_cp") private String userCp; //@Pattern(regexp="[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}",message="${message[valEmail]}") @Column(name = "user_email") private String userEmail; @Column(name = "user_tel") private String userTel; @Column(name = "user_gsm") private String userGsm; @Column(name = "user_createDate") private Date userCreateDate; @Column(name = "user_isAdmin") private boolean userIsAdmin; @Column(name = "user_isValide") private boolean userIsValide; public User() { } public User(String userLogin, String userPswd, String userNom, String userPrenom, String userAdresse, String userCp, String userEmail, String userTel, String userGsm, Date userCreateDate) { this.userLogin = userLogin; this.userPswd = userPswd; this.userNom = userNom; this.userPrenom = userPrenom; this.userAdresse = userAdresse; this.userCp = userCp; this.userEmail = userEmail; this.userTel = userTel; this.userGsm = userGsm; this.userCreateDate = userCreateDate; } public Integer getUserId() { return this.userId; } public void setUserId(Integer userId) { this.userId = userId; } /** * @param userLogin * @param userPswd * @param userNom * @param userPrenom * @param userAdresse * @param userCp * @param userEmail * @param userTel * @param userGsm * @param userCreateDate * @param userIsAdmin * @param userIsValide */ public User(String userLogin, String userPswd, String userNom, String userPrenom, String userAdresse, String userCp, String userEmail, String userTel, String userGsm, Date userCreateDate, boolean userIsAdmin, boolean userIsValide) { super(); this.userLogin = userLogin; this.userPswd = userPswd; this.userNom = userNom; this.userPrenom = userPrenom; this.userAdresse = userAdresse; this.userCp = userCp; this.userEmail = userEmail; this.userTel = userTel; this.userGsm = userGsm; this.userCreateDate = userCreateDate; this.userIsAdmin = userIsAdmin; this.userIsValide = userIsValide; } public String getUserLogin() { return this.userLogin; } public void setUserLogin(String userLogin) { this.userLogin = userLogin; } public String getUserPswd() { return this.userPswd; } public void setUserPswd(String userPswd) { this.userPswd = userPswd; } public String getUserNom() { return this.userNom; } public void setUserNom(String userNom) { this.userNom = userNom; } public String getUserPrenom() { return this.userPrenom; } public void setUserPrenom(String userPrenom) { this.userPrenom = userPrenom; } public String getUserAdresse() { return this.userAdresse; } public void setUserAdresse(String userAdresse) { this.userAdresse = userAdresse; } public String getUserCp() { return this.userCp; } public void setUserCp(String userCp) { this.userCp = userCp; } public String getUserEmail() { return this.userEmail; } public void setUserEmail(String userEmail) { this.userEmail = userEmail; } public String getUserTel() { return this.userTel; } public void setUserTel(String userTel) { this.userTel = userTel; } public String getUserGsm() { return this.userGsm; } public void setUserGsm(String userGsm) { this.userGsm = userGsm; } public Date getUserCreateDate() { return this.userCreateDate; } public String getUserCreateDateFormat() { SimpleDateFormat formater = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss"); return formater.format(this.userCreateDate); } public void setUserCreateDate(Date userCreateDate) { this.userCreateDate = userCreateDate; } public boolean isUserIsAdmin() { return userIsAdmin; } public void setUserIsAdmin(boolean userIsAdmin) { this.userIsAdmin = userIsAdmin; } public boolean isUserIsValide() { return userIsValide; } public void setUserIsValide(boolean userIsValide) { this.userIsValide = userIsValide; } }
Mon hibernate-context.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
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource"> <property name="basenames"> <list> <value>classpath:locale/message</value> </list> </property> <property name="defaultEncoding" value="UTF-8"/> </bean> <bean id="localeResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver"> <property name="defaultLocale" value="fr" /> </bean> <mvc:interceptors> <!-- Changes the locale when a 'locale' request parameter is sent; e.g. /?locale=de --> <bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"> <property name="paramName" value="lang" /> </bean> </mvc:interceptors> <context:component-scan base-package="com.starterSpring.controller.user" /> <mvc:resources mapping="/resources/**" location="/resources/" /> <mvc:annotation-driven /> <!-- Load Hibernate related configuration --> <import resource="hibernate-context.xml" /> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/user/" /> <property name="suffix" value=".jsp" /> </bean> </beans>
mon fichier proprettes
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 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd "> <context:property-placeholder location="/WEB-INF/spring.properties" /> <!-- Enable annotation style of managing transactions --> <tx:annotation-driven transaction-manager="transactionManager" /> <!-- Declare the Hibernate SessionFactory for retrieving Hibernate sessions --> <!-- See http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/orm/hibernate3/annotation/AnnotationSessionFactoryBean.html --> <!-- See http://docs.jboss.org/hibernate/stable/core/api/index.html?org/hibernate/SessionFactory.html --> <!-- See http://docs.jboss.org/hibernate/stable/core/api/index.html?org/hibernate/Session.html --> <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean" p:dataSource-ref="dataSource" p:configLocation="${hibernate.config}" p:packagesToScan="modele.DAO.beans.user"/> <!-- Session Factory Declaration <bean id="SessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="annotatedClasses"> <list> <value>modele.DAO.beans.user.User</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop> <prop key="hibernate.show_sql">true</prop> </props> </property> </bean>--> <!-- <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"> <property name="configLocation" value="classpath:hibernate.cfg.xml"/> </bean>--> <!-- Declare a datasource that has pooling capabilities--> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close" p:driverClass="com.mysql.jdbc.Driver" p:jdbcUrl="jdbc:mysql://localhost:3306/gestImmo" p:user="root" p:password="" p:acquireIncrement="5" p:idleConnectionTestPeriod="60" p:maxPoolSize="100" p:maxStatements="50" p:minPoolSize="10" /> <!-- Declare a transaction manager--> <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager" p:sessionFactory-ref="sessionFactory" /> </beans>
et pour finir hibernante.cfg.xml
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8# database properties app.jdbc.driverClassName=com.mysql.jdbc.Driver app.jdbc.url=jdbc:mysql://localhost:3306/gestImmo app.jdbc.username=root app.jdbc.password= #hibernate properties hibernate.config=/WEB-INF/hibernate.cfg.xml
Merci de votre aide parce je déprime sur cette bêtise depuis une semaine!
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 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <!-- We're using MySQL database so the dialect needs to MySQL as well--> <property name="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property> <!-- Enable this to see the SQL statements in the logs--> <property name="show_sql">false</property> <!-- This will drop our existing database and re-create a new one. Existing data will be deleted! --> <property name="hbm2ddl.auto">create</property> </session-factory> </hibernate-configuration>
Partager