Announcement Announcement Module
Collapse
No announcement yet.
Property 'dataSource' is required Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Property 'dataSource' is required

    my xml file:

    PHP Code:
    <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
          </
    bean>    
          <
    bean id="dataSource" 
          
    class="org.springframework.jdbc.datasource.DriverManagerDataSource"
        <
    property name="driverClassName"
           <
    value>oracle.jdbc.driver.OracleDriver</value
        </
    property
        <
    property name="url"
           <
    value>jdbc:oracle:thin:@10.237.204.86:1521:CDOI1</value
        </
    property
        <
    property name="username"
           <
    value>CDO</value
        </
    property
        <
    property name="password"
           <
    value>CDO</value
        </
    property
      </
    bean
    getting following error:

    PHP Code:
    org.springframework.beans.factory.BeanCreationExceptionError creating bean with name 'jdbcTemplate' defined in class path resource [com/sp/cms/cdointerface/portlet/controller/AssetsPortfoli-datasource.xml]: Invocation of init method failednested exception is java.lang.IllegalArgumentExceptionProperty 'dataSource' is required
    Caused by
    java.lang.IllegalArgumentExceptionProperty 'dataSource' is required
        at org
    .springframework.jdbc.support.JdbcAccessor.afterPropertiesSet(JdbcAccessor.java:134)
        
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1143)
        
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1110)
        
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:431)
        
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:254)
        
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:144)
        
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:251)
        
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:163)
        
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:284)
        
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
        
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:91)
        
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:75)
        
    at com.sp.cms.cdointerface.portlet.controller.TestController.main(TestController.java:12)
    Exception in thread "main" 

  • #2
    This is expected. You didn't wire the dataSource bean to the dataSource-property of your JdbcTemplate.

    Comment


    • #3
      got it, data soursce was missing in jdbctemplate
      PHP Code:
      <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
              <
      property name="dataSource"><ref bean="dataSource" /></property>
       </
      bean

      Comment

      Working...
      X