Bonjour,
Je suis passé d'Hibernate 3.1.3 à 3.2.5, en utilisant désormais le protocole classpath:// dans les fichiers .hbm, pour faire des inclusions, du genre:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"
[<!ENTITY common SYSTEM "classpath://x/y/z/Common.hbm">]>
<hibernate-mapping package="x.y">
(...)
&common;
(...)
</hibernate-mapping>
Le lancement de mes tests unitaires à la main fonctionne. Par contre, leur lancement depuis une tâche ant génère l'erreur suivante (unknown protocol: classpath):
Code:
test:
[junit] Running appli.test.AllTest
[junit] Testsuite: appli.test.AllTest
[junit] Tests run: 5, Failures: 0, Errors: 1, Time elapsed: 1,86 sec
[junit] Tests run: 5, Failures: 0, Errors: 1, Time elapsed: 1,86 sec
[junit] Testcase: testStringtoArray took 0 sec
[junit] Testcase: testValidate took 0,047 sec
[junit] Testcase: testIsCompatible took 0 sec
[junit] Testcase: testValidateTemporelImpl took 0 sec
[junit] Testcase: testSaveGetUpdateDeleteTypeIntrant took 1,781 sec
[junit] Caused an ERROR
[junit] Error creating bean with name 'sessionFactory' defined in URL [file:W:/OGIVE/dev/appli/WebContent/WEB-INF/applicationContext-general.xml]: Initialization of bean failed; nested exception is org.hibernate.InvalidMappingException: Could not parse mapping document from input stream
[junit] org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in URL [file:W:/OGIVE/dev/appli/WebContent/WEB-INF/applicationContext-general.xml]: Initialization of bean failed; nested exception is org.hibernate.InvalidMappingException: Could not parse mapping document from input stream
[junit] org.hibernate.InvalidMappingException: Could not parse mapping document from input stream
[junit] at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:508)
[junit] at org.springframework.orm.hibernate3.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:679)
[junit] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1091)
[junit] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:396)
[junit] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:233)
[junit] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:145)
[junit] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:277)
[junit] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:313)
[junit] at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:87)
[junit] at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:72)
[junit] at org.springframework.test.AbstractSpringContextTests.loadContextLocations(AbstractSpringContextTests.java:135)
[junit] at org.springframework.test.AbstractDependencyInjectionSpringContextTests.loadContextLocations(AbstractDependencyInjectionSpringContextTests.java:224)
[junit] at org.springframework.test.AbstractSpringContextTests.getContext(AbstractSpringContextTests.java:115)
[junit] at org.springframework.test.AbstractDependencyInjectionSpringContextTests.setUp(AbstractDependencyInjectionSpringContextTests.java:192)
[junit] Caused by: org.dom4j.DocumentException: unknown protocol: classpath Nested exception: [b]unknown protocol: classpath[/b]
[junit] at org.dom4j.io.SAXReader.read(SAXReader.java:484)
[junit] at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:499)
Je n'arrive pas à trouver ce qui ne va pas, bien qu'un problème similaire ait été mentionné ici:
http://forum.hibernate.org/viewtopic.php?p=2372397Ma configuration Ant est la suivante:
Code:
<project name="dev" basedir="../" default="war">
(...)
<!-- Chemins du projet -->
<property file="${basedir}/ant/build.properties"/>
<property name="src.dir" value="${basedir}/src"/>
<property name="webroot.dir" value="${basedir}/WebContent"/>
<property name="webinf.dir" value="${webroot.dir}/WEB-INF"/>
<property name="bin.dir" value="${webinf.dir}/classes"/>
<property name="build.dir" value="build"/>
<property name="doc.dir" value="doc"/>
<property name="doc.javadoc.dir" value="${doc.dir}/javadoc"/>
<property name="doc.jdepend.dir" value="${doc.dir}/jdepend"/>
<property name="doc.javancss.dir" value="${doc.dir}/javaNCSS"/>
<property name="outils.dir" value="outils"/>
<property name="outils.jdepend.dir" value="${outils.dir}/jdepend"/>
<property name="outils.javancss.dir" value="${outils.dir}/javaNCSS"/>
<property name="outils.lib.dir" value="${outils.dir}/lib"/>
<property name="tomcat.dir" value="C:\Tomcat"/>
<property name="tomcat.common.lib.dir" value="${tomcat.dir}/common/lib"/>
<property name="deploy.dir" value="${tomcat.dir}/webapps"/>
<!-- Classpath : librairies JAR du projet -->
<path id="compile.classpath">
<fileset dir="${webinf.dir}/lib">
<include name="*.jar"/>
</fileset>
<pathelement path ="${webinf.dir}/classes"/>
<pathelement path ="${classpath.external}"/>
<pathelement path ="${classpath}"/>
<fileset dir="${tomcat.common.lib.dir}">
<include name="*.jar"/>
</fileset>
</path>
(...)
<!-- Execution des tests JUnit -->
<target name="test" depends="compile" description="Tests unitaires et d'integration avec JUnit">
<junit fork="yes" haltonerror="true" haltonfailure="on" printsummary="on">
<formatter type="plain" usefile="false" />
<test name="appli.test.AllTest"/>
<classpath refid="compile.classpath"/>
</junit>
</target>
(...)
Avez-vous une piste? Je galère et ne trouve pas... ;-)
Merci!