These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Launching JUnit tests with Ant : unknown protocol: classpath
PostPosted: Wed Jan 09, 2008 6:46 am 
Newbie

Joined: Wed Jan 09, 2008 6:26 am
Posts: 19
Hello,

I have upgraded Hibernate from 3.1.3 to 3.2.5, and now i use "classpath" in my .hbm files, in order to include common files, for instance:

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>


JUnit tests run fine from my IDE (Eclipse), but tests crash if i launch them from Ant, with the following error (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)


I am in trouble and don't find any solution. There's a similar probleme here, but it gives me no clues:
http://forum.hibernate.org/viewtopic.php?p=2372397

My Ant configuration is:

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>

        (...)


Could you help me please, any help appreciated!

Thanks in advance!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 09, 2008 12:05 pm 
Newbie

Joined: Wed Jan 09, 2008 6:26 am
Posts: 19
i use ant 1.7.0 ...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 09, 2008 2:19 pm 
Newbie

Joined: Wed Jan 09, 2008 6:26 am
Posts: 19
I finally find the follwing things :
1 - When running JUnit/Ant with the project's classes built by Eclipse, there's no problem
2 - When running JUnit/Ant with the project's classes rebuilt by Ant, it raises the error "unknown protocol: classpath"

So there is a difference between my Eclipse build and my Ant build, but i can't find what!

Do you have any idea what could raise this error? XML parser librairy? Hibernate.jar version???


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 11, 2008 5:00 am 
Newbie

Joined: Wed Jan 09, 2008 6:26 am
Posts: 19
I spent a lot of time and i'm in big trouble, unable to solve this problem.
It isn't at all a JUnit problem, in fact source code built with Ant crashes as soon as executed (but compilation is ok) whereas source code built with Eclipse is fine. The error is "org.dom4j.DocumentException: unknown protocol: classpath Nested exception: unknown protocol: classpath" (at tomcat's startup).

I think there's a problem with a .jar but i've no idea wich one could raise such an error...

Please help me!
Thanks in advance.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.