bonjour à tous,
je suis debutant en develloppement web et j'utilise les frameworks hibernate + spring + spring security + jsf.
lorsque j'exécute mon appli j'obtiens l'erreur suivante :
----------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------
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 SEVERE: Exception lors de l'envoi de l'évènement contexte initialisé (context initialized) à l'instance de classe d'écoute (listener) org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'contactsDao' defined in ServletContext resource [/WEB-INF/ApplicationContext-Dao.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/ApplicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: @OneToOne or @ManyToOne on com.oxia.formation.Contrats.client references an unknown entity: java.lang.String at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:275) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1245) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380) at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4791) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549) at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/ApplicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: @OneToOne or @ManyToOne on com.oxia.formation.Contrats.client references an unknown entity: java.lang.String at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:269) ... 28 more Caused by: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on com.oxia.formation.Contrats.client references an unknown entity: java.lang.String at org.hibernate.cfg.ToOneFkSecondPass.doSecondPass(ToOneFkSecondPass.java:81) at org.hibernate.cfg.AnnotationConfiguration.processFkSecondPassInOrder(AnnotationConfiguration.java:499) at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:304) at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1121) at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:673) at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335) ... 38 more nov. 24, 2012 6:18:41 PM org.apache.catalina.core.StandardContext startInternal SEVERE: Error listenerStart nov. 24, 2012 6:18:41 PM org.apache.catalina.core.StandardContext startInternal SEVERE: Erreur de démarrage du contexte [/GestionContrat] suite aux erreurs précédentes nov. 24, 2012 6:18:41 PM org.apache.catalina.core.ApplicationContext log INFO: Closing Spring root WebApplicationContext nov. 24, 2012 6:18:41 PM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc SEVERE: The web application [/GestionContrat] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered. nov. 24, 2012 6:18:41 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads SEVERE: The web application [/GestionContrat] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak. nov. 24, 2012 6:18:41 PM org.apache.coyote.AbstractProtocol start INFO: Starting ProtocolHandler ["http-bio-8880"] nov. 24, 2012 6:18:41 PM org.apache.coyote.AbstractProtocol start INFO: Starting ProtocolHandler ["ajp-bio-8889"] nov. 24, 2012 6:18:41 PM org.apache.catalina.startup.Catalina start INFO: Server startup in 11632 ms
le fichier ApplicationContext-Dao.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 <?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:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans <a href="http://www.springframework.org/schema/beans/spring-beans-2.5.xsd" target="_blank">http://www.springframework.org/schem...-beans-2.5.xsd</a> <a href="http://www.springframework.org/schema/tx" target="_blank">http://www.springframework.org/schema/tx</a> <a href="http://www.springframework.org/schema/tx/spring-tx-2.5.xsd" target="_blank">http://www.springframework.org/schem...ing-tx-2.5.xsd</a> <a href="http://www.springframework.org/schema/aop" target="_blank">http://www.springframework.org/schema/aop</a> http://www.springframework.org/schema/aop/spring-aop-2.5.xsd"> <!--Transaction management --> <bean id="transactionTemplate" class="org.springframework.transaction.support.TransactionTemplate"> <property name="transactionManager" ref="transactionManager" /> <property name="propagationBehaviorName" value="PROPAGATION_REQUIRED" /> </bean> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <!-- the transactional semantics... --> <tx:attributes> <!-- all methods starting with 'get' are read-only --> <tx:method name="get*" read-only="true" /> <tx:method name="find*" read-only="true" /> <!-- other methods use the default transaction settings (see below) --> <tx:method name="*" propagation="REQUIRED" /> </tx:attributes> </tx:advice> <tx:annotation-driven transaction-manager="transactionManager"/> <!-- Ensure that the above transactional advice runs for any execution of an operation defined by the userManagementService interface --> <aop:config> <aop:pointcut id="managementServiceOperation" expression="execution(* com.oxia.formation.*.*(..))" /> <aop:advisor advice-ref="txAdvice" pointcut-ref="managementServiceOperation" /> </aop:config> </beans>
le bean ContratCtr.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
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 package com.oxia.formation.ctr; import java.io.Serializable; import java.util.List; import javax.annotation.PostConstruct; import javax.faces.application.FacesMessage; import javax.faces.context.FacesContext; import javax.faces.model.DataModel; import javax.faces.model.ListDataModel; import org.springframework.dao.DataIntegrityViolationException; import com.oxia.formation.Contacts; import com.oxia.formation.Contrats; import com.oxia.formation.dao.ContactsDao; import com.oxia.formation.dao.ContratsDao; public class ContactCtr implements Serializable { private static final long serialVersionUID = 1L; private ContratsDao contratsDao; private ContactsDao contactsDao; private DataModel features; private Contacts selectedContact = new Contacts(); private Contacts contact; private List<Contacts> contacts; private List<Contrats> listeContrats; private boolean creation; @PostConstruct public void init() { contacts = contactsDao.getContacts(); features = new ListDataModel(contacts); } public DataModel getFeatures() { contacts = contactsDao.getContacts(); features = new ListDataModel(contacts); return features; } public List<Contacts> getContacts() { contacts = contactsDao.getContacts(); features = new ListDataModel(contacts); return contacts; } public String editContact() { setSelectedContact(contacts.get(features.getRowIndex())); setCreation(false); return "success"; } public String create() { selectedContact = new Contacts(); setCreation(true); return "success"; } public String saveContact() { contact = new Contacts(); contact.setCin(selectedContact.getCin()); contact.setFirstName(selectedContact.getFirstName()); contact.setLastName(selectedContact.getLastName()); contact.setEmail(selectedContact.getEmail()); try { contactsDao.create(selectedContact); } catch (DataIntegrityViolationException e) { FacesContext.getCurrentInstance().addMessage( "Exist", new FacesMessage("L'identifiant saisi existe déjà dans la base")); return "echec"; } return "success"; } public String updateContact() { setCreation(false); contactsDao.update(selectedContact); return "success"; } public String deleteContact() { setCreation(false); contactsDao.delete(contacts.get(features.getRowIndex())); return "success"; } public String getContactById() { setCreation(false); setSelectedContact(contactsDao.findById(selectedContact.getCin())); listeContrats = contratsDao.findContratsByContact(selectedContact.getCin()); return "success"; } public ContactsDao getContactDao() { return contactsDao; } public void setContactsDao(ContactsDao contactsDao) { this.contactsDao = contactsDao; } public Contacts getSelectedContact() { return selectedContact; } public void setSelectedContact(Contacts selectedContact) { this.selectedContact = selectedContact; } public boolean isCreation() { return creation; } public void setCreation(boolean creation) { this.creation = creation; } public ContratsDao getContratsDao() { return contratsDao; } public void setContratsDao(ContratsDao contratsDao) { this.contratsDao = contratsDao; } public List<Contrats> getListeContrats() { return listeContrats; } public void setListeContrats(List<Contrats> listeContrats) { this.listeContrats = listeContrats; } }
le fichier web.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 <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> <display-name>jsfexemple</display-name> <!-- Faces Servlet --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/ApplicationContext*.xml</param-value> </context-param> <context-param> <param-name>javax.faces.CONFIG_FILES</param-name> <param-value> /WEB-INF/faces-config.xml</param-value> </context-param> <context-param> <param-name>javax.faces.DEFAULT_SUFFIX</param-name> <param-value>.xhtml</param-value> </context-param> <context-param> <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name> <param-value>com.sun.facelets.FaceletViewHandler</param-value> </context-param> <listener> <listener-class>com.sun.faces.config.ConfigureListener</listener-class> </listener> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <filter> <display-name>RichFaces Filter</display-name> <filter-name>richfaces</filter-name> <filter-class>org.ajax4jsf.Filter</filter-class> </filter> <filter-mapping> <filter-name>richfaces</filter-name> <servlet-name>Faces Servlet</servlet-name> <url-pattern>/*</url-pattern> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> <dispatcher>INCLUDE</dispatcher> </filter-mapping> <filter> <filter-name>springSecurityFilterChain</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> </filter> <filter-mapping> <filter-name>springSecurityFilterChain</filter-name> <url-pattern>/*</url-pattern> <dispatcher>FORWARD</dispatcher> <dispatcher>REQUEST</dispatcher> </filter-mapping> <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet </servlet-class> <load-on-startup>1</load-on-startup> </servlet> <!-- Faces Servlet Mapping --> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>*.jsf</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> </web-app>
merci de me guider pour la résolution de ce problème.
Partager