Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7518793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:48:02+00:00 2026-05-30T01:48:02+00:00

I try to run JUNIT test with eclipse and ANT they both are complainen

  • 0

I try to run JUNIT test with eclipse and ANT they both are complainen that org.h2.Driver class is not found.

I have h2-1.3.164.jar in my classpath and for proof about it here is classpath from system property java.class.path


c:\trasferer\build;
C:\Program Files (x86)\IBM\IMShared\plugins\org.junit4_4.3.1\junit.jar;
c:\trasferer\lib\ojdbc6.jar;
c:\trasferer\lib\sqljdbc4.jar;
c:\trasferer\lib-test\h2-1.3.164.jar;
c:\trasferer\lib-test\junit-4.8.2.jar;
c:\trasferer\lib-test\log4j-1.2.14.jar;
c:\trasferer\lib-test\TestUtils.jar;
c:\trasferer\lib-test\dbunit-2.4.8.jar;
c:\trasferer\lib-test\slf4j-api-1.5.5.jar;
c:\trasferer\lib-test\slf4j-log4j12-1.5.5.jar;

and I can found class org.h2.Driver from h2-1.3.164.jar when I open it with eclipse.
Ant task for running test and ANT tasks for “build” classpath

<path id="lib.classpath">
    <fileset dir="./lib" includes="*.jar" />
</path>

<path id="test.classpath">
    <fileset dir="lib" includes="*.jar" />
    <fileset dir="lib-test" includes="*.jar" />
    <pathelement location="${dest}" />
    <pathelement location="${test-dest}" />
</path>

<target name="run-test" depends="init-test,compile,compile-test">
    <property name="classPathToUse" refid="test.classpath" />
    <echo>Using classpath: "${classPathToUse}"</echo>
    <junit failureProperty="test.failure" fork="on" forkmode="once" outputtoformatters="true" printsummary="on" showoutput="true">
        <jvmarg value="-Xmx512m" />
        <jvmarg value="-XX:MaxPermSize=128m" />
        <jvmarg value="-Duser.timezone=GMT" />
        <jvmarg value="-Dexternal-properties=${test.properties}" />
        <classpath refid="test.classpath" />
        <formatter type="brief" usefile="false" />
        <formatter type="xml" />
        <batchtest todir="test-results">
            <fileset dir="${test-dest}" includes="**/*Test.class" />
        </batchtest>
    </junit>
    <fail message="test failed" if="test.failure" />
</target>

and here is stacktrace


    [junit] ------------- Standard Error -----------------
    [junit] log4j:ERROR Could not find value for key log4j.appender.CONSOLE
    [junit] log4j:ERROR Could not instantiate appender named "CONSOLE".
    [junit] log4j:WARN No appenders could be found for logger (org.dbunit.DatabaseTestCase).
    [junit] log4j:WARN Please initialize the log4j system properly.
    [junit] ------------- ---------------- ---------------
    [junit] Testcase: testBuildLiityntapisteSQL(org.xyz.rigistry.manager.XXServiceImplTest):     Caused an ERROR
    [junit] org.h2.Driver
    [junit] java.lang.ClassNotFoundException: org.h2.Driver
    [junit]     at java.lang.Class.forName(Class.java:136)
    [junit]     at org.dbunit.JdbcDatabaseTester.(JdbcDatabaseTester.java:104)
    [junit]     at org.dbunit.PropertiesBasedJdbcDatabaseTester.(PropertiesBasedJdbcDatabaseTester.java:68)
    [junit]     at org.dbunit.DBTestCase.newDatabaseTester(DBTestCase.java:70)
    [junit]     at org.dbunit.DatabaseTestCase.getDatabaseTester(DatabaseTestCase.java:109)
    [junit]     at org.dbunit.DatabaseTestCase.setUp(DatabaseTestCase.java:151)
    [junit]     at fi.transferer.junit.AbstractDatabaseTestCase.setUp(Unknown Source)
    [junit]     at fi.transferer.junit.BasicDatabaseTestCase.setUp(Unknown Source)

So could someone tell me what is going on, please?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T01:48:03+00:00Added an answer on May 30, 2026 at 1:48 am

    Could you post the ANT build file section, which runs junit? There are options that switch off use of the CLASSPATH environment variable….


    Relying on environment variables makes your build less portable and in my experience is a very inflexible way to manage your java dependencies. I notice you’re already running into the problem of multiple versions of the same library (two copies of junit and log4j).

    I would suggest altering your build to declare classpaths at the top of the build.xml file as follows:

    <path id="compile.path">
        <fileset dir="c:\trasferer\lib" includes="*.jar"/>
    </path>
    
    <path id="test.path">
        <path refid="compile.path"/>
        <fileset dir="c:\trasferer\lib-test" includes="*.jar"/>
    </path>
    

    These classpaths can then be used in the various ant tasks, using the classpathref attribute:

    <javac srcdir="${src}"
             destdir="${build}"
             classpathref="compile.path"
             debug="on"
             source="1.4"
      />
    

    And junit has a nested classpath capability (useful for adding the compiled classes directory):

    <junit printsummary="yes" haltonfailure="yes">
      <classpath>
        <pathelement location="${build.tests}"/>
        <path refid="test.path"/>
      </classpath>
    
      <formatter type="plain"/>
    
      <test name="my.test.TestCase" haltonfailure="no" outfile="result">
        <formatter type="xml"/>
      </test>
    
      <batchtest fork="yes" todir="${reports.tests}">
        <fileset dir="${src.tests}">
          <include name="**/*Test*.java"/>
          <exclude name="**/AllTests.java"/>
        </fileset>
      </batchtest>
    </junit>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to run a test that written by another programmer with JUnit in
When I try to run a Solr test case from Eclipse (Right-Click > Run
Every time I try to run a small application that uses a Derby DB
whenever I try to run something in Java, Eclipse changes into the PHP perspective.
Whenever i try to run sqlmetal, i get this: 'sqlmetal' is not recognized as
I have a strange issue with JUnit 4 tests in Eclipse 3.5 that I
I'm trying to run Jettys ServletTester in my JUnit test. I created a simple
On NetBeans 6.7.1 with PHPUnit 3.4.1, If I try and run the test I
I am trying to run an ant build script that compiles GWT. This script
I try to run tests from Intellij. Methods I test uses some properties files

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.