ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Preston, Brian" <>
Subject junit task classpath issue, can't find jdbc drivers?
Date Fri, 07 Sep 2007 18:18:33 GMT
Is there a common 'gotcha' with running the junit task and classpaths?
Because I'm having a problem where my tests run against the database, so
they need the drivers on the classpath, and they're not being found.
Here's the error : 
java.sql.SQLException: No suitable driver at
java.sql.DriverManager.getConnection(Unknown Source) 

When I run the Junit in Eclipse, it works fine. I have the db drivers on
the classpath, but I must be missing something. 

We have a utility project (DataConn) for handling db connections. It
contains examples that require the db drivers. When I compile this
project earlier in the build script, it compiles fine. I tried
commenting out the classpath ref that has the drivers on it, just to
test it, and it fails. 

For the junit classpath, I have a refid that points to the classpath
used by the DataConn project. But apparently something is wrong. 

I'll try to include relevant snippets of the build file 

<path id="DataConn.classpath">
    <fileset dir="${DataConn.lib}">
        <patternset refid="jar-files" />

DataConn.lib is where the driver jars are. Again, I tested that this is
working because the compilation of the DataConn project works with this
classpath, and fails when it's commented out. 

<path id="test.classpath">
    <fileset file="${junit.jar}"/>
    <path refid="MainProj.classpath"/>
    <pathelement location="${MainProj.bin}"/>
    <pathelement location="${test.dir}"/>
    <!-- need the db drivers -->
    <path refid="DataConn.classpath"/>
<target name="test.compile" depends="MainProj.compile">
        <javac srcdir="${test.src}" destdir="${test.dir}"
classpathref="test.classpath" />
<target name="test" depends="test.compile">
    <junit haltonfailure="true" printsummary="true">
    	<classpath refid="test.classpath" />
    	<test name="com.mycompany.project.TestSuiteFooImpl" />
    	<formatter type="brief" usefile="false"/>

FYI, the test.compile target step is successful as well. 

In the test suite, there is a static initializer method which sets the
'jdbc.drivers' System property with a semicolon-delimited list of the
drivers. Then it does other calls to our DataConn project to set up the
connection pool. This all works fine when running this suite from within

I'm using ant 1.7 on WinXP. Any gotchas in this area I should look for?
Any ideas? 

This e-mail message is intended only for the personal use of the 
recipient(s) named above. If you are not an intended recipient,  
you may not review, copy or distribute this message. If you have  
received this communication in error, please notify First DataBank 
Support ( immediately by e-mail  
and delete the original message. 

  • Unnamed multipart/alternative (inline, 7-Bit, 0 bytes)
View raw message