Results 1 to 4 of 4

Thread: JUnit setup issue

  1. #1
    Join Date
    Jul 2006
    Posts
    1

    Default JUnit setup issue

    Hi all, I'm sure there are developers who are using eclipse to run JUnit test. My problem is though I've "naming-factory-dbcp.jar" path defined in the class path (I think so) but the classloader can't find it. My unit test cases are extended from AbstractDependencyInjectionSpringContextTests.
    Here is the error I get:
    org.springframework.beans.factory.BeanDefinitionSt oreException: Error registering bean with name 'dataSource' defined in class path resource [applicationContext.xml]: Bean class [org.apache.commons.dbcp.BasicDataSource] not found; nested exception is java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource

    I'm using eclipse 3.2 with tomcat 5.5 and Tomcat 5.5 runtime defined in the "java build path". I also tried adding the tomcat folder explicitly in the java build path (using add class folder/create new folder and then map tomcat lib with the new folder) but still the classloader fails to load the class. I can resolve the problem by coping the jar but I hate the duplicating(you know why). What're the best practices to run spring JUnit tests under eclipse with respect to setting the libraries ?

    thanks in advance
    Susanta

  2. #2
    Join Date
    Jul 2006
    Posts
    5

    Default

    As BasicDataSource is part of the commons-dbcp project and is built on using pooling functionality provided by the commons-pool project you'll have to add two jars:
    • commons-dbcp.jar
    • commons-pool.jar


    http://jakarta.apache.org/commons/dbcp/

    greets

  3. #3
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    667

    Lightbulb Just an Eclipse question?

    Quote Originally Posted by sdatta
    What're the best practices to run spring JUnit tests under eclipse with respect to setting the libraries ?
    JUnit (when run via Eclipse) automatically uses any libraries that are in your Eclipse project's build path. So this isn't a Spring or even a JUnit question; it's more a case of "What're the best practices for eclipse with respect to setting my project's build path?". In which case my answer would be "use Maven"!

    HTH,
    Andrew Swan
    "Now is the EJB of our discontent made glorious Spring"

  4. #4
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    Or you can use c3p0 which from my experience performs better, is actively maintained and has more configuration options.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •