Results 1 to 3 of 3

Thread: Declaring 2 datasources in applicationContext.xml file.

  1. #1
    Join Date
    Apr 2008
    Posts
    29

    Default Declaring 2 datasources in applicationContext.xml file.

    Hi All,

    I need to connect to two different datasources so I declared below way in applicationContext.xml file

    Code:
    <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiName" value="eDB" /> 
    	</bean>
    	
    	<bean id="sybaseSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    		<property name="jndiName" value="cDB" />
    	</bean>
    
    	<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
    		<property name="dataSource" ref="dataSource" />
    	</bean>
    	
    	
    
    	<bean id="sybaseTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
    		<property name="sybaseSource" ref="sybaseSource" />
    	</bean>
    When I try to deploy application, it is throwing below error

    Code:
    org.springframework.beans.InvalidPropertyException: Invalid property 'sybaseSour
    ce' of bean class [org.springframework.jdbc.core.JdbcTemplate]: No property 'sybaseSource' found
            at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrap
    perImpl.java:382)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBean
    Factory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1253)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBean
    Factory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1214)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBean
    Factory.populateBean(AbstractAutowireCapableBeanFactory.java:978)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBean
    Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:462)
            Truncated. see log file for complete stacktrace
    I don't understand why 'jdbcTemplate' is referring 'sybaseSource'?? can anyone please suggest me how to resolve this issue.

    Thanks in advance.

    Regards,
    Sharath.

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    Well have you actually looked at

    1. The stacktrace
    2. Your configuration....

    Code:
    	<bean id="sybaseTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
    		<property name="sybaseSource" ref="sybaseSource" />
    	</bean>
    Trust me when I say that there is no property named sybaseSource on the JdbcTemplate... (As the stacktrace quite clearly tells you)...
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Apr 2008
    Posts
    29

    Default Declaring 2 datasources in applicationContext.xml file.

    Hi Marten,

    Yeah, I figured out this problem. Now I changed the declaration and it is working fine.

    Code:
    <bean id="sybaseTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
    		<property name="dataSource" ref="sybaseSource" />
    	</bean>
    Thanks,
    Sharath.

Posting Permissions

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