Results 1 to 4 of 4

Thread: org.springframework.beans.factory.CannotLoadBeanCl assException

  1. #1
    Join Date
    May 2008
    Posts
    2

    Unhappy org.springframework.beans.factory.CannotLoadBeanCl assException

    hi all!,
    I am trying to integrate spring with ibatis. And I am getting the following errors. I am trying a lot but unable to resolve the issue. The error which I am getting is pasted below. Please help me out to get this done.
    Thanks

    org.springframework.beans.factory.CannotLoadBeanCl assException: Cannot find class [org.apache.commons.dbcp.BasicDataSource] for bean with name 'dataSource' defined in class path resource [applicationContext.xml]; nested exception is java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource
    Caused by: java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at org.springframework.util.ClassUtils.forName(ClassU tils.java:201)
    at org.springframework.beans.factory.support.Abstract BeanDefinition.resolveBeanClass(AbstractBeanDefini tion.java:327)
    at org.springframework.beans.factory.support.Abstract BeanFactory.resolveBeanClass(AbstractBeanFactory.j ava:1075)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:282)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:352)
    at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:91)
    at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:75)
    at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:65)
    at com.developersBook.iBatis.client.IBatisClient.main (IBatisClient.java:14)

  2. #2
    Join Date
    Mar 2008
    Posts
    10

    Default

    Add common-dbcp.jar to your classpath. You can get it from spring-framework\lib\jakarta-commons.

  3. #3
    Join Date
    May 2008
    Posts
    2

    Default org.springframework.beans.factory.CannotLoadBeanCl assException

    I have already added the common-dbcp.jar file.
    My error is removed if I add the following line

    <bean id="dataSource" class="org.springframework.jdbc.datasource.SingleC onnectionDataSource" destroy-method="destroy">

    instead of

    <bean id="dataSource"
    class="org.apache.commons.dbcp.BasicDataSource"
    destroy-method="close">

    in applicationContext.xml. You have any idea why it is so.

    Thanks

  4. #4
    Join Date
    May 2007
    Location
    Netherlands
    Posts
    614

    Default

    you're posting this on the wrong forum, but it looks like a collision. Could it be that you have multiple versions on your classpath?

Posting Permissions

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