Announcement Announcement Module
Collapse
No announcement yet.
Accessing data from 3 different datasource Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Accessing data from 3 different datasource

    Hi,

    I have requirement to access data from 3 different data source pointing to different database.

    I am using org.apache.commons.dbcp.BasicDataSource in my applicationContext.xml file to create datasource. so how can I create multiple of these.

    Can you please with example.

  • #2
    do you have to merge the results of all datasources ?
    If not, you can take several persistance units ( in several persistence.xml files ) and configure several EntityManagerFactories with the persistenceXmlLocation property.
    Then you have to inject each EntityManagerFactory specifically into the according DAO's

    Comment


    • #3
      Originally posted by srigold View Post
      Hi,

      I have requirement to access data from 3 different data source pointing to different database.

      I am using org.apache.commons.dbcp.BasicDataSource in my applicationContext.xml file to create datasource. so how can I create multiple of these.

      Can you please with example.
      If you know in advance db you need to query agains it is not a problem. Just define multiple datasources.

      If determination is made at runtime consider using routingdatasource.
      Take a look at forum.

      Comment


      • #4
        Originally posted by miluch View Post
        If you know in advance db you need to query agains it is not a problem. Just define multiple datasources.

        If determination is made at runtime consider using routingdatasource.
        Take a look at forum.
        What if I need to merge the results of all the datasource? Does that mean I will only need 1 EntityManagerFactory connecting to all the datasource?

        Comment


        • #5
          Originally posted by JuneGal View Post
          What if I need to merge the results of all the datasource? Does that mean I will only need 1 EntityManagerFactory connecting to all the datasource?
          So i am not JPA guy, so i can just tell you that one SessionFactory = one DataSource.

          So if you have a requirements to access multiple datasources (DBs) you need to define 3 datasources beans. That's all.

          if you plan to use ORM mapping you just need to wire each dataSource to each ... (In hibernate it is SessionFactory)

          If you plan to use multiple datasources in one transaction unit and just want to get ACID property of transaction do not forget about JTA transaction manager

          Comment


          • #6
            Thank you for replying. I have implemented the multiple datasource with JOTM as well, but is having the following error:

            Code:
            org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'adminService': Injection of persistence methods failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [javax.persistence.EntityManagerFactory] is defined: expected single bean but found 2
            	at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessPropertyValues(PersistenceAnnotationBeanPostProcessor.java:324)
            	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:996)
            	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:470)
            	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
            	at java.security.AccessController.doPrivileged(Native Method)
            	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
            	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
            	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:217)
            	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
            	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
            	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
            	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
            	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729)
            	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381)
            	at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
            	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
            	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
            	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3764)
            	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4216)
            	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
            	at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
            	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
            	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
            	at org.apache.catalina.core.StandardService.start(StandardService.java:448)
            	at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
            	at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
            	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
            	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
            	at java.lang.reflect.Method.invoke(Unknown Source)
            	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
            	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
            Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [javax.persistence.EntityManagerFactory] is defined: expected single bean but found 2
            	at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findDefaultEntityManagerFactory(PersistenceAnnotationBeanPostProcessor.java:513)
            	at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findEntityManagerFactory(PersistenceAnnotationBeanPostProcessor.java:473)
            	at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.resolveEntityManager(PersistenceAnnotationBeanPostProcessor.java:598)
            	at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.getResourceToInject(PersistenceAnnotationBeanPostProcessor.java:569)
            	at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:192)
            	at org.springframework.beans.factory.annotation.InjectionMetadata.injectMethods(InjectionMetadata.java:117)
            	at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessPropertyValues(PersistenceAnnotationBeanPostProcessor.java:321)
            	... 31 more

            My applicationContext.xml
            Code:
            <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
            
            	<bean id="adminService" class="service.AdminService" />	
            	
            	<bean id="emfOmstrade"
            		class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
            		<property name="dataSource" ref="dsOmstrade" />
            		<property name="jpaVendorAdapter">
            			<bean
            				class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
            				<property name="database" value="SQL_SERVER" />
            				<property name="showSql" value="true" />
            			</bean>
            		</property>
            	</bean>
            	
            	<bean id="emfOmsweb"
            		class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
            		<property name="dataSource" ref="dsOmsweb" />
            		<property name="jpaVendorAdapter">
            			<bean
            				class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
            				<property name="database" value="SQL_SERVER" />
            				<property name="showSql" value="true" />
            			</bean>
            		</property>
            	</bean>
            
            	<bean id="dsOmsweb"
            		class="org.enhydra.jdbc.standard.StandardXADataSource">
            		<property name="transactionManager" ref="jotm" />
            		<property name="driverName"
            			value="net.sourceforge.jtds.jdbc.Driver" />
            		<property name="url"
            			value="y" />
            		<property name="user" value="user" />
            		<property name="password" value="password" />
            	</bean>
            
            	<bean id="dsOmstrade"
            		class="org.enhydra.jdbc.standard.StandardXADataSource">
            		<property name="transactionManager" ref="jotm" />
            		<property name="driverName"
            			value="net.sourceforge.jtds.jdbc.Driver" />
            		<property name="url"
            			value="x" />
            		<property name="user" value="user" />
            		<property name="password" value="password" />
            	</bean>
            
            	<bean id="jotm"
            		class="org.springframework.transaction.jta.JotmFactoryBean" />
            
            	<bean id="txManager"
            		class="org.springframework.transaction.jta.JtaTransactionManager">
            		<property name="userTransaction" ref="jotm" />
            	</bean>
            
            	<tx:annotation-driven transaction-manager="txManager" />
            
            	<bean id="adminAction" scope="prototype"
            		class="action.AdminAction">
            		<constructor-arg ref="adminService" />
            	</bean>
            From the error, I know the system can't tell which datasource to use but I have no idea how to tell the adminService bean which datasource to use. Shld it be specify in the applicationContext or in the class itself? Please advice.

            Comment


            • #7
              As stated above i am not JPA guy but the exception you got is because autowire postprocessing finds multiple beans of certain type.

              If you use @Autowired add aditional annotation @Qualifier to distinguish what bean you want Spring to inject.

              look in manual for details
              Last edited by miluch; Sep 11th, 2008, 10:23 AM.

              Comment


              • #8
                News?

                Originally posted by JuneGal View Post
                Thank you for replying. I have implemented the multiple datasource with JOTM as well, but is having the following error:

                Code:
                org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'adminService': Injection of persistence methods failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [javax.persistence.EntityManagerFactory] is defined: expected single bean but found 2
                	at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessPropertyValues(PersistenceAnnotationBeanPostProcessor.java:324)
                	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:996)
                	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:470)
                	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
                	at java.security.AccessController.doPrivileged(Native Method)
                	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
                	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
                	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:217)
                	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
                	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
                	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
                	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
                	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729)
                	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381)
                	at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
                	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
                	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
                	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3764)
                	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4216)
                	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
                	at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
                	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
                	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
                	at org.apache.catalina.core.StandardService.start(StandardService.java:448)
                	at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
                	at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
                	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                	at java.lang.reflect.Method.invoke(Unknown Source)
                	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
                	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
                Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [javax.persistence.EntityManagerFactory] is defined: expected single bean but found 2
                	at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findDefaultEntityManagerFactory(PersistenceAnnotationBeanPostProcessor.java:513)
                	at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findEntityManagerFactory(PersistenceAnnotationBeanPostProcessor.java:473)
                	at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.resolveEntityManager(PersistenceAnnotationBeanPostProcessor.java:598)
                	at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.getResourceToInject(PersistenceAnnotationBeanPostProcessor.java:569)
                	at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:192)
                	at org.springframework.beans.factory.annotation.InjectionMetadata.injectMethods(InjectionMetadata.java:117)
                	at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessPropertyValues(PersistenceAnnotationBeanPostProcessor.java:321)
                	... 31 more

                My applicationContext.xml
                Code:
                <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
                
                	<bean id="adminService" class="service.AdminService" />	
                	
                	<bean id="emfOmstrade"
                		class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
                		<property name="dataSource" ref="dsOmstrade" />
                		<property name="jpaVendorAdapter">
                			<bean
                				class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                				<property name="database" value="SQL_SERVER" />
                				<property name="showSql" value="true" />
                			</bean>
                		</property>
                	</bean>
                	
                	<bean id="emfOmsweb"
                		class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
                		<property name="dataSource" ref="dsOmsweb" />
                		<property name="jpaVendorAdapter">
                			<bean
                				class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                				<property name="database" value="SQL_SERVER" />
                				<property name="showSql" value="true" />
                			</bean>
                		</property>
                	</bean>
                
                	<bean id="dsOmsweb"
                		class="org.enhydra.jdbc.standard.StandardXADataSource">
                		<property name="transactionManager" ref="jotm" />
                		<property name="driverName"
                			value="net.sourceforge.jtds.jdbc.Driver" />
                		<property name="url"
                			value="y" />
                		<property name="user" value="user" />
                		<property name="password" value="password" />
                	</bean>
                
                	<bean id="dsOmstrade"
                		class="org.enhydra.jdbc.standard.StandardXADataSource">
                		<property name="transactionManager" ref="jotm" />
                		<property name="driverName"
                			value="net.sourceforge.jtds.jdbc.Driver" />
                		<property name="url"
                			value="x" />
                		<property name="user" value="user" />
                		<property name="password" value="password" />
                	</bean>
                
                	<bean id="jotm"
                		class="org.springframework.transaction.jta.JotmFactoryBean" />
                
                	<bean id="txManager"
                		class="org.springframework.transaction.jta.JtaTransactionManager">
                		<property name="userTransaction" ref="jotm" />
                	</bean>
                
                	<tx:annotation-driven transaction-manager="txManager" />
                
                	<bean id="adminAction" scope="prototype"
                		class="action.AdminAction">
                		<constructor-arg ref="adminService" />
                	</bean>
                From the error, I know the system can't tell which datasource to use but I have no idea how to tell the adminService bean which datasource to use. Shld it be specify in the applicationContext or in the class itself? Please advice.
                hello! I'm receiving the same error, any news/solution in that?
                Thanks!

                Comment


                • #9
                  Originally posted by JuneGal View Post
                  Thank you for replying. I have implemented the multiple datasource with JOTM as well, but is having the following error:

                  Code:
                  org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'adminService': Injection of persistence methods failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [javax.persistence.EntityManagerFactory] is defined: expected single bean but found 2
                  	at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessPropertyValues(PersistenceAnnotationBeanPostProcessor.java:324)
                  	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:996)
                  	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:470)
                  	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
                  	at java.security.AccessController.doPrivileged(Native Method)
                  	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
                  	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
                  	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:217)
                  	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
                  	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
                  	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
                  	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
                  	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729)
                  	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381)
                  	at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
                  	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
                  	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
                  	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3764)
                  	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4216)
                  	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
                  	at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
                  	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
                  	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
                  	at org.apache.catalina.core.StandardService.start(StandardService.java:448)
                  	at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
                  	at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
                  	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                  	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                  	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                  	at java.lang.reflect.Method.invoke(Unknown Source)
                  	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
                  	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
                  Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [javax.persistence.EntityManagerFactory] is defined: expected single bean but found 2
                  	at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findDefaultEntityManagerFactory(PersistenceAnnotationBeanPostProcessor.java:513)
                  	at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findEntityManagerFactory(PersistenceAnnotationBeanPostProcessor.java:473)
                  	at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.resolveEntityManager(PersistenceAnnotationBeanPostProcessor.java:598)
                  	at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.getResourceToInject(PersistenceAnnotationBeanPostProcessor.java:569)
                  	at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:192)
                  	at org.springframework.beans.factory.annotation.InjectionMetadata.injectMethods(InjectionMetadata.java:117)
                  	at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessPropertyValues(PersistenceAnnotationBeanPostProcessor.java:321)
                  	... 31 more

                  My applicationContext.xml
                  Code:
                  <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
                  
                  	<bean id="adminService" class="service.AdminService" />	
                  	
                  	<bean id="emfOmstrade"
                  		class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
                  		<property name="dataSource" ref="dsOmstrade" />
                  		<property name="jpaVendorAdapter">
                  			<bean
                  				class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                  				<property name="database" value="SQL_SERVER" />
                  				<property name="showSql" value="true" />
                  			</bean>
                  		</property>
                  	</bean>
                  	
                  	<bean id="emfOmsweb"
                  		class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
                  		<property name="dataSource" ref="dsOmsweb" />
                  		<property name="jpaVendorAdapter">
                  			<bean
                  				class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                  				<property name="database" value="SQL_SERVER" />
                  				<property name="showSql" value="true" />
                  			</bean>
                  		</property>
                  	</bean>
                  
                  	<bean id="dsOmsweb"
                  		class="org.enhydra.jdbc.standard.StandardXADataSource">
                  		<property name="transactionManager" ref="jotm" />
                  		<property name="driverName"
                  			value="net.sourceforge.jtds.jdbc.Driver" />
                  		<property name="url"
                  			value="y" />
                  		<property name="user" value="user" />
                  		<property name="password" value="password" />
                  	</bean>
                  
                  	<bean id="dsOmstrade"
                  		class="org.enhydra.jdbc.standard.StandardXADataSource">
                  		<property name="transactionManager" ref="jotm" />
                  		<property name="driverName"
                  			value="net.sourceforge.jtds.jdbc.Driver" />
                  		<property name="url"
                  			value="x" />
                  		<property name="user" value="user" />
                  		<property name="password" value="password" />
                  	</bean>
                  
                  	<bean id="jotm"
                  		class="org.springframework.transaction.jta.JotmFactoryBean" />
                  
                  	<bean id="txManager"
                  		class="org.springframework.transaction.jta.JtaTransactionManager">
                  		<property name="userTransaction" ref="jotm" />
                  	</bean>
                  
                  	<tx:annotation-driven transaction-manager="txManager" />
                  
                  	<bean id="adminAction" scope="prototype"
                  		class="action.AdminAction">
                  		<constructor-arg ref="adminService" />
                  	</bean>
                  From the error, I know the system can't tell which datasource to use but I have no idea how to tell the adminService bean which datasource to use. Shld it be specify in the applicationContext or in the class itself? Please advice.
                  I also have the same problem. Please, somebody helps
                  __________________
                  Find all answers of "what where and how" here| | Newest posts of whatwherenhow.com

                  Comment


                  • #10
                    Check this post that I'm summarizing my digging!

                    http://forum.springsource.org/showthread.php?p=273072

                    Lets share thoughts!!!

                    Comment

                    Working...
                    X