title: Grails - Multiple Datasources
body: <p>First, let me start that I have looked so many sites about the "correct" way to configure multiple datasource on Grails, every one of them (with Grails 2.0 and later) pointing to the <a href="http://grails.org/doc/2.1.0/guide/single.html#multipleDatasources" rel="noreferrer"> docs </a>, however after doing what the docs says I get this error: </p>
  
  <pre><code>Error 2014-03-29 15:48:29,219 [localhost-startStop-1] ERROR context.GrailsContextLoader      - Error initializing the application: Error creating bean with name 'transactionManager_lookup': Cannot resolve reference to bean 'sessionFactory_lookup' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory_lookup': Cannot resolve reference to bean 'transactionManager' while setting bean property 'transactionManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean '$primaryTransactionManager' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '$primaryTransactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'transactionManager' while setting bean property 'transactionManager'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'transactionManager': Requested bean is currently in creation: Is there an unresolvable circular reference?
  Message: Error creating bean with name 'transactionManager_lookup': Cannot resolve reference to bean 'sessionFactory_lookup' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory_lookup': Cannot resolve reference to bean 'transactionManager' while setting bean property 'transactionManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean '$primaryTransactionManager' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '$primaryTransactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'transactionManager' while setting bean property 'transactionManager'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'transactionManager': Requested bean is currently in creation: Is there an unresolvable   circular reference?
  </code></pre>
  
  <p>What I find most interesting is that if I specify:</p>
  
  <pre><code>dataSource_lookup
  </code></pre>
  
  <p>I will get:</p>
  
  <pre><code>Error initializing the application: Error creating bean with name     'transactionManager_lookup'
  </code></pre>
  
  <p>And if I change it to:</p>
  
  <pre><code>dataSource_mysqldb
  </code></pre>
  
  <p>I get:</p>
  
  <pre><code>Error initializing the application: Error creating bean with name 'transactionManager_mysqldb'
  </code></pre>
  
  <p>If I don't specify a second datasource, everything works just fine.</p>
  
  <p>My code:</p>
  
  <pre><code>dataSource {
   logSql = true
   pooled = true
   dialect = org.hibernate.dialect.MySQLInnoDBDialect
   driverClassName = 'com.mysql.jdbc.Driver'
   username = 'myuser'
   password = 'mypass'
   url = 'jdbc:mysql://localhost/mydatabase'
   dbCreate = 'update'
  }
  
  dataSource_mysql {
   dialect = org.hibernate.dialect.MySQLInnoDBDialect
   driverClassName = 'com.mysql.jdbc.Driver'
   username = 'myuser'
   password = 'mypass'
   url = 'jdbc:mysql://localhost/mydatabase'
   dbCreate = 'update'
  }
  
  dataSource_oracle {
   dialect = org.hibernate.dialect.Oracle10gDialect
   driverClassName = 'oracle.jdbc.driver.OracleDriver'
   username = 'myuser'
   password = 'mypass'
   url = 'jdbc:oracle:thin:@localhost:1521:mydatabase'
   dbCreate = 'update'
  }
  </code></pre>
  
  <p>What am I doing wrong here? (As stated before, if I eliminate the two secondary dataSources (dataSource_mysql and dataSource_oracle) everything works just fine).</p>
  
  <p>Thanks in advance.
  Dev: Ubuntu - Grails 2.3.7 - MySQL - Oracle 11g.</p>