[Spring Tests] - pb fichier de mapping
Salut à tous,
J'ai un pb avec mon fichier de mapping xml lorsque je cherche à utiliser une classe de test avec spring.
J'utilise : AbstractTransactionalSpringContextTests
1. La classe de test
Code:
1 2 3 4 5 6 7 8 9 10 11 12
|
public class UneClassDAOHibernateTest extends
AbstractTransactionalSpringContextTests {
...
@Override
protected String[] getConfigLocations() {
return new String[] {"file:applicationContext-hibernate.xml"};
}
} |
2. le fichier de mapping xml :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
</bean>
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
... mes autres bean.
</beans> |
3. L'erreur de la classe de test :
Code:
1 2 3
|
org.springframework.beans.factory.BeanDefinitionStoreException: Line 4 in XML document from URL [file:applicationContext-hibernate.xml] is invalid; nested exception is org.xml.sax.SAXParseException: Document root element "beans", must match DOCTYPE root "null".
org.xml.sax.SAXParseException: Document root element "beans", must match DOCTYPE root "null". |
Résolu : j'ai ajouté une doctype et supprimmé les attributs de <beans> et ça marche.