|
I've installed the Datasources plugin and the test project works fine, however I am unable to use it with my own project and I can't figure out why. The domain classes that should be accessed from the secondary datasource are always accessed from the core, resulting in errors such as:
Error 500: org.hibernate.exception.SQLGrammarException: could not execute query Servlet: grails URI: /affiliates/grails/activityReport.dispatch Exception Message: Table 'mmh.activity_report' doesn't exist Caused by: org.hibernate.exception.SQLGrammarException: could not execute query Class: ActivityReportController At Line: [8] Below are my configurations, if anyone sees any reason why this shouldn't work, please advise. Any help is appreciated. Datasource.groovy: dataSource { pooled = true driverClassName = "com.mysql.jdbc.Driver" } hibernate { show_sql=true cache.use_second_level_cache=false cache.use_query_cache=false } // environment specific settings environments { development { dataSource { url = "jdbc:mysql://localhost/mmh" username = "root" password = "" } } test { dataSource { url = "jdbc:mysql://localhost/mmh" username = "root" password = "" } } production { dataSource { url = "jdbc:mysql://localhost/mmh" username = "root" password = "" } } } Datasources.groovy: datasources = { datasource(name: 'mmhadmin') { driverClassName('com.mysql.jdbc.Driver') url('jdbc:mysql://localhost/mmhadmin') username('root') password('') domainClasses([com.mmh.affiliates.domain.ActivityReport]) logSql(true) pooled(true) environments(['development','test','production']) hibernate { cache { use_second_level_cache(false) use_query_cache(false) } } } } ActivityReport.groovy (domain class that will not access correctly -- this is a legacy table and does not have a primary key): package com.mmh.affiliates.domain class ActivityReport { static mapping = { txnid column: 'TRANSACTION_ID' discountAmt column: 'DISCOUNT_AMT' doctorComAmt column: 'DOCTOR_COM_AMT' salesRepComAmt column: 'SALES_REP_COM_AMT' version false } String txnid double discountAmt double doctorComAmt double salesRepComAmt } When I start the application via "grails run-app" I see the following messages: Welcome to Grails 1.1.1 - http://grails.org/ Licensed under Apache Standard License 2.0 Grails home is set to: /devtools/grails Base Directory: /Users/bbrown/work/affiliates Running script /devtools/grails/scripts/RunApp.groovy Environment set to development [copy] Copied 6 empty directories to 2 empty directories under /Users/bbrown/.grails/1.1.1/projects/affiliates/resources [mkdir] Created dir: /Users/bbrown/.grails/1.1.1/projects/affiliates/classes [groovyc] Compiling 8 source files to /Users/bbrown/.grails/1.1.1/projects/affiliates/classes [groovyc] Compiling 23 source files to /Users/bbrown/.grails/1.1.1/projects/affiliates/classes [mkdir] Created dir: /Users/bbrown/.grails/1.1.1/projects/affiliates/resources/grails-app/i18n [native2ascii] Converting 11 files from /Users/bbrown/work/affiliates/grails-app/i18n to /Users/bbrown/.grails/1.1.1/projects/affiliates/resources/grails-app/i18n [copy] Copying 1 file to /Users/bbrown/.grails/1.1.1/projects/affiliates/classes [copy] Copied 2 empty directories to 2 empty directories under /Users/bbrown/.grails/1.1.1/projects/affiliates/resources Running Grails application.. Datasources Datasources Server running. Browse to http://localhost:8080/affiliates I can provide more information if needed. Thanks in advance for any assistance. |
|
I sent a message to the author of this post. He found his problem and here's his response. hope it helps someone else :) bye "My problems were two-fold. 1) The config file for the plugin needs to be named Datasources.groovy, not DataSources.groovy. 2) You MUST define a dialect... it's ok to omit it from the main grails config, but not from the plugin config. Ex: dialect('org.hibernate.dialect.MySQL5InnoDBDialect') Hope this helps. -Ben" benfreefly wrote: > > I've installed the Datasources plugin and the test project works fine, > however I am unable to use it with my own project and I can't figure out > why. The domain classes that should be accessed from the secondary > datasource are always accessed from the core, resulting in errors such as: > > Error 500: org.hibernate.exception.SQLGrammarException: could not execute > query > Servlet: grails > URI: /affiliates/grails/activityReport.dispatch > Exception Message: Table 'mmh.activity_report' doesn't exist > Caused by: org.hibernate.exception.SQLGrammarException: could not execute > query > Class: ActivityReportController > At Line: [8] > > Below are my configurations, if anyone sees any reason why this shouldn't > work, please advise. Any help is appreciated. > > Datasource.groovy: > > dataSource { > pooled = true > driverClassName = "com.mysql.jdbc.Driver" > } > hibernate { > show_sql=true > cache.use_second_level_cache=false > cache.use_query_cache=false > } > // environment specific settings > environments { > development { > dataSource { > url = "jdbc:mysql://localhost/mmh" > username = "root" > password = "" > } > } > test { > dataSource { > url = "jdbc:mysql://localhost/mmh" > username = "root" > password = "" > } > } > production { > dataSource { > url = "jdbc:mysql://localhost/mmh" > username = "root" > password = "" > } > } > } > > > > Datasources.groovy: > > datasources = { > > datasource(name: 'mmhadmin') { > driverClassName('com.mysql.jdbc.Driver') > url('jdbc:mysql://localhost/mmhadmin') > username('root') > password('') > domainClasses([com.mmh.affiliates.domain.ActivityReport]) > logSql(true) > pooled(true) > environments(['development','test','production']) > hibernate { > cache { > use_second_level_cache(false) > use_query_cache(false) > } > } > } > } > > > > ActivityReport.groovy (domain class that will not access correctly -- this > is a legacy table and does not have a primary key): > > package com.mmh.affiliates.domain > > class ActivityReport { > > static mapping = { > txnid column: 'TRANSACTION_ID' > discountAmt column: 'DISCOUNT_AMT' > doctorComAmt column: 'DOCTOR_COM_AMT' > salesRepComAmt column: 'SALES_REP_COM_AMT' > version false > } > > String txnid > double discountAmt > double doctorComAmt > double salesRepComAmt > } > > > > When I start the application via "grails run-app" I see the following > messages: > > Welcome to Grails 1.1.1 - http://grails.org/ > Licensed under Apache Standard License 2.0 > Grails home is set to: /devtools/grails > > Base Directory: /Users/bbrown/work/affiliates > Running script /devtools/grails/scripts/RunApp.groovy > Environment set to development > [copy] Copied 6 empty directories to 2 empty directories under > /Users/bbrown/.grails/1.1.1/projects/affiliates/resources > [mkdir] Created dir: > /Users/bbrown/.grails/1.1.1/projects/affiliates/classes > [groovyc] Compiling 8 source files to > /Users/bbrown/.grails/1.1.1/projects/affiliates/classes > [groovyc] Compiling 23 source files to > /Users/bbrown/.grails/1.1.1/projects/affiliates/classes > [mkdir] Created dir: > /Users/bbrown/.grails/1.1.1/projects/affiliates/resources/grails-app/i18n > [native2ascii] Converting 11 files from > /Users/bbrown/work/affiliates/grails-app/i18n to > /Users/bbrown/.grails/1.1.1/projects/affiliates/resources/grails-app/i18n > [copy] Copying 1 file to > /Users/bbrown/.grails/1.1.1/projects/affiliates/classes > [copy] Copied 2 empty directories to 2 empty directories under > /Users/bbrown/.grails/1.1.1/projects/affiliates/resources > Running Grails application.. > Datasources > Datasources > Server running. Browse to http://localhost:8080/affiliates > > > I can provide more information if needed. Thanks in advance for any > assistance. > -- View this message in context: http://old.nabble.com/Grails-Datasources-Plugin-Problem-tp26417972p26635945.html Sent from the grails - user mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
In reply to this post by benfreefly
I sent a message to the author of this post. He found his problem and here's his response. hope it helps someone else :) bye "My problems were two-fold. 1) The config file for the plugin needs to be named Datasources.groovy, not DataSources.groovy. 2) You MUST define a dialect... it's ok to omit it from the main grails config, but not from the plugin config. Ex: dialect('org.hibernate.dialect.MySQL5InnoDBDialect') Hope this helps. -Ben" benfreefly wrote: > > I've installed the Datasources plugin and the test project works fine, > however I am unable to use it with my own project and I can't figure out > why. The domain classes that should be accessed from the secondary > datasource are always accessed from the core, resulting in errors such as: > > Error 500: org.hibernate.exception.SQLGrammarException: could not execute > query > Servlet: grails > URI: /affiliates/grails/activityReport.dispatch > Exception Message: Table 'mmh.activity_report' doesn't exist > Caused by: org.hibernate.exception.SQLGrammarException: could not execute > query > Class: ActivityReportController > At Line: [8] > > Below are my configurations, if anyone sees any reason why this shouldn't > work, please advise. Any help is appreciated. > > Datasource.groovy: > > dataSource { > pooled = true > driverClassName = "com.mysql.jdbc.Driver" > } > hibernate { > show_sql=true > cache.use_second_level_cache=false > cache.use_query_cache=false > } > // environment specific settings > environments { > development { > dataSource { > url = "jdbc:mysql://localhost/mmh" > username = "root" > password = "" > } > } > test { > dataSource { > url = "jdbc:mysql://localhost/mmh" > username = "root" > password = "" > } > } > production { > dataSource { > url = "jdbc:mysql://localhost/mmh" > username = "root" > password = "" > } > } > } > > > > Datasources.groovy: > > datasources = { > > datasource(name: 'mmhadmin') { > driverClassName('com.mysql.jdbc.Driver') > url('jdbc:mysql://localhost/mmhadmin') > username('root') > password('') > domainClasses([com.mmh.affiliates.domain.ActivityReport]) > logSql(true) > pooled(true) > environments(['development','test','production']) > hibernate { > cache { > use_second_level_cache(false) > use_query_cache(false) > } > } > } > } > > > > ActivityReport.groovy (domain class that will not access correctly -- this > is a legacy table and does not have a primary key): > > package com.mmh.affiliates.domain > > class ActivityReport { > > static mapping = { > txnid column: 'TRANSACTION_ID' > discountAmt column: 'DISCOUNT_AMT' > doctorComAmt column: 'DOCTOR_COM_AMT' > salesRepComAmt column: 'SALES_REP_COM_AMT' > version false > } > > String txnid > double discountAmt > double doctorComAmt > double salesRepComAmt > } > > > > When I start the application via "grails run-app" I see the following > messages: > > Welcome to Grails 1.1.1 - http://grails.org/ > Licensed under Apache Standard License 2.0 > Grails home is set to: /devtools/grails > > Base Directory: /Users/bbrown/work/affiliates > Running script /devtools/grails/scripts/RunApp.groovy > Environment set to development > [copy] Copied 6 empty directories to 2 empty directories under > /Users/bbrown/.grails/1.1.1/projects/affiliates/resources > [mkdir] Created dir: > /Users/bbrown/.grails/1.1.1/projects/affiliates/classes > [groovyc] Compiling 8 source files to > /Users/bbrown/.grails/1.1.1/projects/affiliates/classes > [groovyc] Compiling 23 source files to > /Users/bbrown/.grails/1.1.1/projects/affiliates/classes > [mkdir] Created dir: > /Users/bbrown/.grails/1.1.1/projects/affiliates/resources/grails-app/i18n > [native2ascii] Converting 11 files from > /Users/bbrown/work/affiliates/grails-app/i18n to > /Users/bbrown/.grails/1.1.1/projects/affiliates/resources/grails-app/i18n > [copy] Copying 1 file to > /Users/bbrown/.grails/1.1.1/projects/affiliates/classes > [copy] Copied 2 empty directories to 2 empty directories under > /Users/bbrown/.grails/1.1.1/projects/affiliates/resources > Running Grails application.. > Datasources > Datasources > Server running. Browse to http://localhost:8080/affiliates > > > I can provide more information if needed. Thanks in advance for any > assistance. > -- View this message in context: http://old.nabble.com/Grails-Datasources-Plugin-Problem-tp26417972p26635946.html Sent from the grails - user mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
In reply to this post by benfreefly
I sent a message to the author of this post. He found his problem and here's his response.
hope it helps someone else :) bye "My problems were two-fold. 1) The config file for the plugin needs to be named Datasources.groovy, not DataSources.groovy. 2) You MUST define a dialect... it's ok to omit it from the main grails config, but not from the plugin config. Ex: dialect('org.hibernate.dialect.MySQL5InnoDBDialect') Hope this helps. -Ben" |
|
In reply to this post by benfreefly
Hi,
Please confirm that you have added following line in your "application.properties" to make sure that your Grails Runtime can have access to "Datasources" plugin plugins.datasources=0.3
--
Thanks And Regards, Yagnesh Chawda. http://yagneshchawda.blogspot.com http://twitter.com/yagneshchawda ************************************************ Good planets are hard to find. Print less! Save energy to keep your future bright !! ************************************************ "Earth provides enough to satisfy every man's need, but not every man's greed." - Mahatma Gandhi ************************************************ |
| Powered by Nabble | Edit this page |
