J'ai fait une chtite appli utilisant Hibernate, j'ai voulu y intégrer Spring, mais
j'ai une erreur dont je ne vois pas la cause :
(sûrement un truc con, mais ça m'énerve !!!)
Mon fichier de config Spring :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'HibernateUtil' defined in file [D:\Utilisat\a432566\Mes Documents\Workspace\HibernateOmegaPersonne2mergeSpring\src\hibernate.spring.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 file [D:\Utilisat\a432566\Mes Documents\Workspace\HibernateOmegaPersonne2mergeSpring\src\hibernate.spring.xml]: Initialization of bean failed; nested exception is net.sf.hibernate.MappingException: org.dom4j.DocumentException: hibernate.sourceforge.net Nested exception: hibernate.sourceforge.net org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'SessionFactory' defined in file [D:\Utilisat\a432566\Mes Documents\Workspace\HibernateOmegaPersonne2mergeSpring\src\hibernate.spring.xml]: Initialization of bean failed; nested exception is net.sf.hibernate.MappingException: org.dom4j.DocumentException: hibernate.sourceforge.net Nested exception: hibernate.sourceforge.net net.sf.hibernate.MappingException: org.dom4j.DocumentException: hibernate.sourceforge.net Nested exception: hibernate.sourceforge.net ... 16:11:47,268 ERROR Configuration:295 - Could not configure datastore from input stream
Appel dans l'appli :
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 <beans> <bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/> <property name="url" value="XXX"/> <property name="username" value="XXX"/> <property name="password" value="XXX"/> </bean> <bean id="SessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean"> <property name="dataSource" ref="myDataSource"/> <property name="mappingResources"> <list> <value>unidirectionnel/mappings/personne.hbm.xml</value> <value>unidirectionnel/mappings/telephone.hbm.xml</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">net.sf.hibernate.dialect.Oracle9Dialect</prop> </props> </property> </bean> <bean id="HibernateUtil" class="util.HibernateUtil"> <property name="sessionFactory" ref="SessionFactory"/> </bean> </beans>
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 BeanFactory factory = new XmlBeanFactory(new FileSystemResource("src/hibernate.spring.xml")); gs=(HibernateUtil)factory.getBean("HibernateUtil"); //Plante ici !!!! :( s = gs.getCurrentSession();
Partager