Announcement Announcement Module
Collapse
No announcement yet.
Exception injecting JDBCTemplate into SimpleJdbcDaoSupport Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Exception injecting JDBCTemplate into SimpleJdbcDaoSupport

    Hi,

    I have a DAO IndividualStructureCdbDAO that extends SimpleJdbcDaoSupport.
    While injecting JDBCTemplate I am getting following exception:


    : java.lang.IllegalArgumentException: 'dataSource' or 'jdbcTemplate' is required

    at org.springframework.jdbc.core.support.JdbcDaoSuppo rt.checkDaoConfig(J
    dbcDaoSupport.java:112)
    at org.springframework.dao.support.DaoSupport.afterPr opertiesSet(DaoSupp
    ort.java:44)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBean
    Factory$5.run(AbstractAutowireCapableBeanFactory.j ava:1450)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBean
    Factory.invokeInitMethods(AbstractAutowireCapableB eanFactory.java:1448)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBean
    Factory.initializeBean(AbstractAutowireCapableBean Factory.java:1400)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBean
    Factory.doCreateBean(AbstractAutowireCapableBeanFa ctory.java:513)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBean
    Factory.createBean(AbstractAutowireCapableBeanFact ory.java:450)
    at org.springframework.beans.factory.support.Abstract BeanFactory$1.getOb
    ject(AbstractBeanFactory.java:290)
    at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistr
    y.getSingleton(DefaultSingletonBeanRegistry.java:2 22)
    at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBe
    an(AbstractBeanFactory.java:287)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean
    (AbstractBeanFactory.java:189)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.
    preInstantiateSingletons(DefaultListableBeanFactor y.java:562)
    at org.springframework.context.support.AbstractApplic ationContext.finish
    BeanFactoryInitialization(AbstractApplicationConte xt.java:871)
    at org.springframework.context.support.AbstractApplic ationContext.refres
    h(AbstractApplicationContext.java:423)
    at org.openspaces.pu.container.integrated.IntegratedP rocessingUnitContai
    nerProvider.createContainer(IntegratedProcessingUn itContainerProvider.java:268)
    at org.openspaces.pu.container.servicegrid.PUServiceB eanImpl.startPU(PUS
    erviceBeanImpl.java:553)
    at org.openspaces.pu.container.servicegrid.PUServiceB eanImpl.doStart(PUS
    erviceBeanImpl.java:180)
    at org.jini.rio.jsb.ServiceBeanAdapter$1.run(ServiceB eanAdapter.java:291
    )
    at org.jini.rio.jsb.ServiceBeanAdapter.start(ServiceB eanAdapter.java:304
    )
    at org.jini.rio.jsb.JSBLoader.create(JSBLoader.java:1 06)
    at org.jini.rio.cybernode.ServiceBeanLoader.load(Serv iceBeanLoader.java:
    279)


    What I am doing wrong.
    Below is my Spring configuration file. I am new to Spring framework.


    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:util="http://www.springframework.org/schema/util"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schem...ring-beans.xsd
    http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">


    <!-- BEGIN: DATA ACCESS -->

    <bean
    class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer">
    <property name="location">
    <value>env_dev.properties</value>
    </property>
    </bean>

    <bean id="cdbDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
    <property name="jdbcUrl" value="${ds.cdb.jdbcUrl}" />
    <property name="driverClass" value="${ds.cdb.driverClass}" />
    <property name="user" value="${ds.cdb.userId}" />
    <property name="password" value="${ds.cdb.password}" />
    <property name="maxStatements" value="180" /> <!-- PreparedStatement pooling -->
    <property name="minPoolSize" value="${ds.cdb.minSize}" />
    <property name="maxPoolSize" value="${ds.cdb.maxSize}" />
    <property name="acquireIncrement" value="${ds.cdb.acquireIncrement}" />
    <property name="maxIdleTime" value="${ds.cdb.maxIdleTime}" />
    </bean>

    <bean id="individualStructureCdbDAO" class="com.ge.comfin.fleet.dao.IndividualStructure CdbDAO">
    <property name="jdbcTemplate">
    <bean class="org.springframework.jdbc.core.JdbcTemplate" >
    <property name="dataSource" ref="cdbDataSource"/>
    </bean>
    </property>
    <property name="location">
    <bean class="org.springframework.core.io.ClassPathResour ce">
    <constructor-arg value="individual-query.xml" />
    </bean>
    </property>
    <property name="howMany" value="10000" />
    </bean>

    <bean id="individualStructureSpaceDAO" class="com.ge.comfin.fleet.dao.IndividualStructure SpaceDAO" />
    </beans>


    Thanks

  • #2
    Use [ code][/code ] tags when posting code !!!

    You are defining 2 dao's and only one has a JdbcTemplate.

    Comment

    Working...
    X