Hi ,
ApplicationContext context = new ClassPathXmlApplicationContext("Spring-Module.xml");
AccountDao customerDAO = (AccountDao) context.getBean("accountDAO");
Spring-Module.xml
<import resource="/Spring-Datasource.xml" />
<import resource="/Spring-Customer.xml" />
Spring-Customer.xml
<bean id="accountDAO" class="com.raghu.spring3.controller.AccountDaoImpl ">
<property name="dataSource" ref="dataSource" />
</bean>
Spring-Datasource.xml
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverM anagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/test" />
<property name="username" value="root" />
<property name="password" value="root" />
</bean>
May i know why i am getting following error
org.springframework.web.util.NestedServletExceptio n: Request processing failed; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'dataSource' defined in class path resource [com/spring3/controller/context.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: org/apache/commons/pool/impl/GenericObjectPool
org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:656)
org.springframework.web.servlet.FrameworkServlet.d oGet(FrameworkServlet.java:549)
javax.servlet.http.HttpServlet.service(HttpServlet .java:617)
javax.serv


Reply With Quote
