i develop a grails 1.3.7 and i now trying to deploy it on amazon cloud. i follow the steps explained on http://www.inoneo.com/en/blog/5/amazon-aws/deploy-a-grails-application-on-aws-elastic-beanstalk. amazon instance tomcat version is 7. I am able to connect using mysql native to amazon database. my production environment configuration is:
production {
dataSource {
user = "{userDB}"
password = "{passDB}"
pooled = true
dbCreate = "create"
driverClassName = "com.mysql.jdbc.Driver"
url = "jdbc:mysql://{endPointRSD}:3306/{databaseName}?user={userDB}&password={passDB}"
dialect = org.hibernate.dialect.MySQL5InnoDBDialect
properties {
validationQuery = "SELECT 1"
testOnBorrow = true
testOnReturn = true
testWhileIdle = true
timeBetweenEvictionRunsMillis = 1800000
numTestsPerEvictionRun = 3
minEvictableIdleTimeMillis = 1800000
}
}
}
However i get several errors. Seems to me i having troubles with transactional issues. But how can it happen when my app run just fine in development? Thanks
here goes the error
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#3': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'claseDemandaService': Cannot create inner bean '(inner bean)' while setting bean property 'target'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#3': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'usuarioService': Cannot resolve reference to bean 'transactionManager' while setting bean property 'transactionManager'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'transactionManager' is defined
... 3 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'claseDemandaService': Cannot create inner bean '(inner bean)' while setting bean property 'target'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#3': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'usuarioService': Cannot resolve reference to bean 'transactionManager' while setting bean property 'transactionManager'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'transactionManager' is defined
... 3 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#3': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'usuarioService': Cannot resolve reference to bean 'transactionManager' while setting bean property 'transactionManager'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'transactionManager' is defined
... 3 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'usuarioService': Cannot resolve reference to bean 'transactionManager' while setting bean property 'transactionManager'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'transactionManager' is defined
... 3 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'transactionManager' is defined
... 3 more
2014-09-13 13:51:42,393 [http-bio-8080-exec-5] ERROR errors.GrailsExceptionResolver - Exception occurred when processing request: [GET] /principal/encabezado
Related
I get the following error when executing my Grails application in Spring Tool Suite:
| Error 2015-06-12 18:19:18,357 [localhost-startStop-1] ERROR hbm2ddl.SchemaUpdate - Unsuccessful: alter table meta_data_master_template add index FK6FD57D1CFA081AA2 (protocol_id), add constraint FK6FD57D1CFA081AA2 foreign key (protocol_id) references protocol (protocol_id)
| Error 2015-06-12 18:19:18,357 [localhost-startStop-1] ERROR hbm2ddl.SchemaUpdate - Cannot add or update a child row: a foreign key constraint fails (datumrite.#sql-1204_4, CONSTRAINT FK6FD57D1CFA081AA2 FOREIGN KEY (protocol_id) REFERENCES protocol (protocol_id))
| Error 2015-06-12 18:19:21,887 [localhost-startStop-1] ERROR context.GrailsContextLoader - Error executing bootstraps: Error creating bean with name 'org.grails.activiti.springsecurity.SetAuthenticatedUserIdFilters': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'processEngine': Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: Lorg/apache/ibatis/session/SqlSessionFactory;
Message: Error creating bean with name 'org.grails.activiti.springsecurity.SetAuthenticatedUserIdFilters': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'processEngine': Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: Lorg/apache/ibatis/session/SqlSessionFactory;
Caused by BeanCreationException: Error creating bean with name 'processEngine': Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: Lorg/apache/ibatis/session/SqlSessionFactory;
as the message suggests, drop the CONSTRAINT FK6FD57D1CFA081AA2 from your DB and try again. Alternatively you can remove dbCreate = "update" from your DataSource
In my config.groovy file I am connecting to MongoDB like so
environments {
production {
// db.configuration.file=System.getProperty("user.home") + "/mydb.cfg"
grails.mongo.host = "Snip Snip" //dataSourcesConfig.get 'host'
grails.mongo.databaseName = 'edupal' //dataSourcesConfig.get 'dbname'
grails.mongo.username = 'admin' //dataSourcesConfig.get 'user'
grails.mongo.password = 'V********k' //dataSourcesConfig.get 'password'
}
development {
grails.mongo.databaseName = 'edupal'
}
}
when I deploy my .war file the page appears blank because I am getting this error in my TOMCAT log. I am 110% certain the password and username that I use are correct. When I
go to RockMongo and login, I copy and paste. I can run the app perfectly off my local machine.
Caused by: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'transactionManager': Cannot resolve
reference to bean 'mongoTransactionManager' while setting constructor
argument with key [1]; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'mongoTransactionManager': Cannot resolve
reference to bean 'mongoDatastore' while setting bean property
'datastore'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'mongoDatastore': FactoryBean threw exception
on object creation; nested exception is
org.springframework.data.mongodb.CannotGetMongoDbConnectionException:
Failed to authenticate to database [edupal], username = [admin],
password = [V********k] ... 5 more Caused by:
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'mongoTransactionManager': Cannot resolve
reference to bean 'mongoDatastore' while setting bean property
'datastore'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'mongoDatastore': FactoryBean threw exception
on object creation; nested exception is
org.springframework.data.mongodb.CannotGetMongoDbConnectionException:
Failed to authenticate to database [edupal], username = [admin],
password = [V********k] ... 5 more Caused by:
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'mongoDatastore': FactoryBean threw exception
on object creation; nested exception is
org.springframework.data.mongodb.CannotGetMongoDbConnectionException:
Failed to authenticate to database [edupal], username = [admin],
password = [V********k] ... 5 more Caused by:
org.springframework.data.mongodb.CannotGetMongoDbConnectionException:
Failed to authenticate to database [edupal], username = [admin],
password = [V********k] at
org.grails.datastore.mapping.mongo.MongoDatastore.initializeIndices(MongoDatastore.java:285)
at
org.grails.datastore.mapping.mongo.MongoDatastore.createMongoTemplate(MongoDatastore.java:276)
at
org.grails.datastore.mapping.mongo.MongoDatastore.afterPropertiesSet(MongoDatastore.java:221)
at
org.grails.datastore.gorm.mongo.bean.factory.MongoDatastoreFactoryBean.getObject(MongoDatastoreFactoryBean.groovy:54)
... 5 more
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 docs , however after doing what the docs says I get this error:
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?
What I find most interesting is that if I specify:
dataSource_lookup
I will get:
Error initializing the application: Error creating bean with name 'transactionManager_lookup'
And if I change it to:
dataSource_mysqldb
I get:
Error initializing the application: Error creating bean with name 'transactionManager_mysqldb'
If I don't specify a second datasource, everything works just fine.
My 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'
}
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).
Thanks in advance.
Dev: Ubuntu - Grails 2.3.7 - MySQL - Oracle 11g.
Ok I figured this out.
In the Grails 2.3.7 release notes it says to upgrade your hibernate version. I failed to do that.
http://grails.org/2.3.7+Release+Notes
runtime ':hibernate:3.6.10.10'
Then after I did that I stopped getting that error and got another error
java.lang.ClassNotFoundException: null
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at ....MigrationUtils.createInstance(MigrationUtils.groovy:220)
at ....MigrationUtils.getDatabase(MigrationUtils.groovy:57)
at ....MigrationUtils.getDatabase(MigrationUtils.groovy:116)
at DbmGenerateGormChangelog$_...doCall(DbmGenerateGormChangelog:52)
at ....MigrationUtils.executeInSession(MigrationUtils.groovy:132)
at DbmGenerateGormChangelog$_run_closure2.doCall(DbmGenerateGormChangelog:51)
at DbmGenerateGormChangelog$_run_closure1.doCall(DbmGenerateGormChangelog:33)
I've never had to specify the hibernate dialect for oracle before, but apparently in the most recent version of the migrations plugin (1.3.8 currently), you have to.
dialect = "org.hibernate.dialect.Oracle10gDialect"
I was already specifying the dialect for MySQL so I don't know if it would produce the same error if removed.
Why am I getting this error when i use grails run-app?
Error 2014-03-03 13:31:30,283 [localhost-startStop-1] ERROR
context.GrailsContextLoader - Error initializing the application:
Error creating bean with name 'transactionManagerPostProcessor':
Initialization of bean failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'transactionManager': 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': Invocation of init method
failed; nested exception is groovy.lang.MissingPropertyException: No
such property: min for class: org.example.shalu.Task Possible
solutions: id, all Message: Error creating bean with name
'transactionManagerPostProcessor': Initialization of bean failed;
nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'transactionManager': 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': Invocation of init method
failed; nested exception is groovy.lang.MissingPropertyException: No
such property: min for class: org.example.shalu.Task Possible
solutions: id, all
If you look closely you will see that you are trying to reference min on the class org.example.shalu.Task which doesn't exist. It's possible that you are doing something in Bootstrap.groovy?
You probably created a Service which is does not have a coordinating logic between domain classes (that means there is no domain class for that service).
If this is the case, then add : static transactional = false to the service.
class MyService {
**static transactional = false**
}
More info: http://grails.org/doc/2.3.x/guide/services.html
oh this one comes when your database setting
either not mapped with exact
database``serverrunning ,
grails can cannot connect to it , check
yourpasswordand
usernameand
check yourdatabase name
check yourdata source setting`
And check your connection String URL on datasource like
dataSource {
pooled = true
dbCreate = "update"
url = "jdbc:mysql://localhost/yourDB"
driverClassName = "com.mysql.jdbc.Driver"
username = "yourUser"
password = "yourPassword"
}
DUDE!!
I am pretty new to Grails and am trying to learn things from the 'Grails in Action' book. I have this example which asks to change the dataSource url in the DataSource.groovy file and when I do that I get an error. Here are the changes and the error. Can anyone help me out? Thanks in advance,
previous:
dataSource {
dbCreate = "update" // one of 'create', 'create-drop', 'update', 'validate', ''
url = "jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
After Change:
dataSource {
dbCreate = "update" // one of 'create', 'create-drop', 'update', 'validate', ''
url = "jdbc:hsqldb:file:devDB;shutdown=true"
Error:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManagerPostProcessor':
Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'transactionManager':
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 'hibernateProperties' while setting bean property 'hibernateProperties'; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'hibernateProperties':
Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'dialectDetector':
Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException:
Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException:
Cannot create JDBC driver of class 'org.h2.Driver' for connect URL 'jdbc:hsqldb:file:devDB;shutdown=true' (Use --stacktrace to see the full trace)
You've changed H2 to HSQLDB - you need to add corresponding dependency to BuildConfig.groovy:
dependencies {
runtime 'hsqldb:hsqldb:1.8.0.10'
}
Also use the following driver in DataSource.groovy:
driverClassName = "org.hsqldb.jdbcDriver"