Announcement Announcement Module
Collapse
No announcement yet.
JUnit setup issue Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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

    Comment


    • #3
      Just an Eclipse question?

      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,

      Comment


      • #4
        Or you can use c3p0 which from my experience performs better, is actively maintained and has more configuration options.

        Comment

        Working...
        X