I have an Amazon ec2 mysql database which I connected in my local machine. I have created a database in it named locker.
And I uncommented the line in BuildConfig.groovy to add mysql connector.
Here is my DataSource.groovy file :
dataSource {
pooled = true
driverClassName = "com.mysql.jdbc.Driver"
dialect = "org.hibernate.dialect.MySQL5InnoDBDialect"
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = false
cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
}
// environment specific settings
environments {
development {
dataSource {
dbCreate = "create" // one of 'create', 'create-drop', 'update', 'validate', ''
url = "jdbc:mysql://localhost/locker?useUnicode=yes&characterEncoding=UTF-8"
username = "anto"
password = "****"
}
hibernate {
show_sql = true
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:h2:prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
pooled = true
properties {
maxActive = -1
minEvictableIdleTimeMillis=1800000
timeBetweenEvictionRunsMillis=1800000
numTestsPerEvictionRun=3
testOnBorrow=true
testWhileIdle=true
testOnReturn=true
validationQuery="SELECT 1"
}
}
}
}
But when I tried to run my grails app I get an big error like this :
Error 2012-07-05 18:54:53,533 [pool-5-thread-1] ERROR context.GrailsContextLoader - Error executing bootstraps: 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 'lobHandlerDetector' while setting bean property 'lobHandler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lobHandlerDetector': 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 PoolableConnectionFactory (Access denied for user 'anto'#'localhost' (using password: YES))
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': Cannot resolve reference to bean 'lobHandlerDetector' while setting bean property 'lobHandler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lobHandlerDetector': 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 PoolableConnectionFactory (Access denied for user 'anto'#'localhost' (using password: YES))
Line | Method
->> 334 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 166 | run in java.util.concurrent.FutureTask
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run . . . in java.lang.Thread
Caused by 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 'lobHandlerDetector' while setting bean property 'lobHandler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lobHandlerDetector': 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 PoolableConnectionFactory (Access denied for user 'anto'#'localhost' (using password: YES))
->> 334 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 166 | run in java.util.concurrent.FutureTask
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run . . . in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'lobHandlerDetector' while setting bean property 'lobHandler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lobHandlerDetector': 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 PoolableConnectionFactory (Access denied for user 'anto'#'localhost' (using password: YES))
->> 334 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 166 | run in java.util.concurrent.FutureTask
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run . . . in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'lobHandlerDetector': 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 PoolableConnectionFactory (Access denied for user 'anto'#'localhost' (using password: YES))
->> 334 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 166 | run in java.util.concurrent.FutureTask
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run . . . in java.lang.Thread
Caused by MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user 'anto'#'localhost' (using password: YES))
->> 334 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 166 | run in java.util.concurrent.FutureTask
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run . . . in java.lang.Thread
Caused by SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user 'anto'#'localhost' (using password: YES))
->> 1549 | createPoolableConnectionFactory in org.apache.commons.dbcp.BasicDataSource
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1388 | createDataSource in ''
| 1044 | getConnection in ''
| 334 | innerRun in java.util.concurrent.FutureTask$Sync
| 166 | run . . . in java.util.concurrent.FutureTask
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run in java.lang.Thread
Caused by SQLException: Access denied for user 'anto'#'localhost' (using password: YES)
->> 1073 | createSQLException in com.mysql.jdbc.SQLError
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 3597 | checkErrorPacket in com.mysql.jdbc.MysqlIO
| 3529 | checkErrorPacket in ''
| 935 | checkErrorPacket in ''
| 4101 | secureAuth411 in ''
| 1300 | doHandshake in ''
| 2337 | coreConnect in com.mysql.jdbc.ConnectionImpl
| 2370 | connectOneTryOnly in ''
| 2154 | createNewIO in ''
| 792 | <init> in ''
| 47 | <init> . in com.mysql.jdbc.JDBC4Connection
| 411 | handleNewInstance in com.mysql.jdbc.Util
| 381 | getInstance in com.mysql.jdbc.ConnectionImpl
| 305 | connect in com.mysql.jdbc.NonRegisteringDriver
| 38 | createConnection in org.apache.commons.dbcp.DriverConnectionFactory
| 582 | makeObject in org.apache.commons.dbcp.PoolableConnectionFactory
| 1556 | validateConnectionFactory in org.apache.commons.dbcp.BasicDataSource
| 1545 | createPoolableConnectionFactory in ''
| 1388 | createDataSource in ''
| 1044 | getConnection in ''
| 334 | innerRun in java.util.concurrent.FutureTask$Sync
| 166 | run in java.util.concurrent.FutureTask
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run . . . in java.lang.Thread
| Error 2012-07-05 18:54:53,630 [pool-5-thread-1] ERROR [localhost].[/locker] - Exception sending context initialized event to listener instance of class org.codehaus.groovy.grails.web.context.GrailsContextLoaderListener
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': Cannot resolve reference to bean 'lobHandlerDetector' while setting bean property 'lobHandler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lobHandlerDetector': 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 PoolableConnectionFactory (Access denied for user 'anto'#'localhost' (using password: YES))
Line | Method
->> 334 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 166 | run in java.util.concurrent.FutureTask
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run . . . in java.lang.Thread
Caused by 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 'lobHandlerDetector' while setting bean property 'lobHandler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lobHandlerDetector': 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 PoolableConnectionFactory (Access denied for user 'anto'#'localhost' (using password: YES))
->> 334 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 166 | run in java.util.concurrent.FutureTask
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run . . . in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'lobHandlerDetector' while setting bean property 'lobHandler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lobHandlerDetector': 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 PoolableConnectionFactory (Access denied for user 'anto'#'localhost' (using password: YES))
->> 334 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 166 | run in java.util.concurrent.FutureTask
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run . . . in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'lobHandlerDetector': 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 PoolableConnectionFactory (Access denied for user 'anto'#'localhost' (using password: YES))
->> 334 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 166 | run in java.util.concurrent.FutureTask
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run . . . in java.lang.Thread
Caused by MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user 'anto'#'localhost' (using password: YES))
->> 334 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 166 | run in java.util.concurrent.FutureTask
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run . . . in java.lang.Thread
Caused by SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user 'anto'#'localhost' (using password: YES))
->> 1549 | createPoolableConnectionFactory in org.apache.commons.dbcp.BasicDataSource
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1388 | createDataSource in ''
| 1044 | getConnection in ''
| 334 | innerRun in java.util.concurrent.FutureTask$Sync
| 166 | run . . . in java.util.concurrent.FutureTask
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run in java.lang.Thread
Caused by SQLException: Access denied for user 'anto'#'localhost' (using password: YES)
->> 1073 | createSQLException in com.mysql.jdbc.SQLError
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 3597 | checkErrorPacket in com.mysql.jdbc.MysqlIO
| 3529 | checkErrorPacket in ''
| 935 | checkErrorPacket in ''
| 4101 | secureAuth411 in ''
| 1300 | doHandshake in ''
| 2337 | coreConnect in com.mysql.jdbc.ConnectionImpl
| 2370 | connectOneTryOnly in ''
| 2154 | createNewIO in ''
| 792 | <init> in ''
| 47 | <init> . in com.mysql.jdbc.JDBC4Connection
| 411 | handleNewInstance in com.mysql.jdbc.Util
| 381 | getInstance in com.mysql.jdbc.ConnectionImpl
| 305 | connect in com.mysql.jdbc.NonRegisteringDriver
| 38 | createConnection in org.apache.commons.dbcp.DriverConnectionFactory
| 582 | makeObject in org.apache.commons.dbcp.PoolableConnectionFactory
| 1556 | validateConnectionFactory in org.apache.commons.dbcp.BasicDataSource
| 1545 | createPoolableConnectionFactory in ''
| 1388 | createDataSource in ''
| 1044 | getConnection in ''
| 334 | innerRun in java.util.concurrent.FutureTask$Sync
| 166 | run in java.util.concurrent.FutureTask
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run . . . in java.lang.Thread
| Error 2012-07-05 18:54:53,655 [pool-5-thread-1] ERROR core.StandardContext - Error listenerStart
| Error 2012-07-05 18:54:53,671 [pool-5-thread-1] ERROR core.StandardContext - Context [/locker] startup failed due to previous errors
I'm very new to grails. What went wrong? Can anyone help me?
Thanks in advance.
It looks like the username and password you are using are not valid:
Access denied for user 'anto'#'localhost' (using password: YES)
This isn't a Grails problem, it's a general permissions problem.
Check out this question. It discusses configuring MySQL to allow remote connections and JDBC. You may need to configure MySQL to allow remote connections because the JDBC drive uses TCP/IP sockets to connect to the database regardless of where the database server is running and where the JDBC client is running.
Well, there might be two reasons(or more) of that problem. One is the permission reason, which you should give to your specific user.
Also, I have noticed that in your DataSource.groovy, the url is set to be:
url = "jdbc:mysql://localhost/locker?useUnicode=yes&characterEncoding=UTF-8"
Just to notice, you might forget to add your mysql port in the url, which would lead to the same problem. The way I did is like:
url = "jdbc:mysql://localhost/locker:1234?useUnicode=yes&characterEncoding=UTF-8"
Related
I am working remotely for a firm based in India and I am connecting to the company network via VPN for daily work.
I am currently implementing a project in grails 2.2.4 which is on my local system / computer. The grails project in GGTS runs fine when connected to the local db on my machine.
But, when I am trying to connect to a database which is hosted in a server on my Company's network from my project's development environment, I am getting a lot of connection errors, all of it from MySQL.
I have configured my DataSource.groovy as below:
dataSource {
pooled = true
driverClassName="com.mysql.jdbc.Driver"
dialect = org.hibernate.dialect.MySQL5InnoDBDialect
username = <username>
password = <password>
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache=true
cache.provider_class='net.sf.ehcache.hibernate.EhCacheProvider'
cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
}
environments {
development {
dataSource {
dbCreate = "update"
url = "jdbc:mysql://<remoteIP-on company network>:3306/<DB_Name>"
properties{
initialSize="50"
maxActive="100"
minIdle="50"
maxIdle="75"
maxWait="30000"
timeBetweenEvictionRunsMillis="5000"
minEvictableIdleTimeMillis="60000"
testWhileIdle="true"
testOnBorrow="true"
testOnReturn="true"
poolPreparedStatements="true"
maxOpenPreparedStatements="100"
validationQuery="SELECT 1 FROM DUAL"
connectionInitSqls="SELECT 1 FROM DUAL"
logAbandoned="true"
}
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:mysql://<remoteIP-on company network>:3306/<DB_Name>"
driverClassName="com.mysql.jdbc.Driver"
username = <username>
password = <password>
}
}
production {
dataSource {
dbCreate = "update"
jndiName = "java:comp/env/<JNDIName>"
properties {
maxActive = 50
maxIdle = 25
minIdle = 5
initialSize = 5
minEvictableIdleTimeMillis = 60000
timeBetweenEvictionRunsMillis = 60000
maxWait = 10000
}
}
}
}
My BuildConfig.groovy has the following dependencies set:
dependencies {
runtime 'mysql:mysql-connector-java:5.1.40'
}
and I have the mysql-connector-java-5.1.40-bin.jar file added to the build path and the /lib/ folder .
On the remote DB, by connecting to it through HeidiSQL client on my machine, I have run the following query based on my research on the same topic of discussion.
GRANT ALL PRIVILEGES ON <DB_Name>.* TO <username>#'%' IDENTIFIED BY <password>;
FLUSH PRIVILEGES;
When I ping to the remote server from the command prompt, that too works fine.
ping <Remote Server IP>
Pinging <Remote Server IP> with 32 bytes of data:
Reply from <Remote Server IP>: bytes=32 time=261ms TTL=61
Reply from <Remote Server IP>: bytes=32 time=261ms TTL=61
Reply from <Remote Server IP>: bytes=32 time=257ms TTL=61
Reply from <Remote Server IP>: bytes=32 time=257ms TTL=61
Ping statistics for <Remote Server IP>:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 257ms, Maximum = 261ms, Average = 259ms
Now, when I run the application using GGTS Run As -> Grails Command (run-app) I get the following error:
| Error 2016-12-13 18:36:05,400 [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': Cannot resolve reference to bean 'lobHandlerDetector' while setting bean property 'lobHandler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lobHandlerDetector': 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 PoolableConnectionFactory (Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.)
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': Cannot resolve reference to bean 'lobHandlerDetector' while setting bean property 'lobHandler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lobHandlerDetector': 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 PoolableConnectionFactory (Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.)
Line | Method
->> 334 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 166 | run in java.util.concurrent.FutureTask
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 724 | run . . . in java.lang.Thread
Caused by 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 'lobHandlerDetector' while setting bean property 'lobHandler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lobHandlerDetector': 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 PoolableConnectionFactory (Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.)
->> 334 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 166 | run in java.util.concurrent.FutureTask
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 724 | run . . . in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'lobHandlerDetector' while setting bean property 'lobHandler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lobHandlerDetector': 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 PoolableConnectionFactory (Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.)
->> 334 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 166 | run in java.util.concurrent.FutureTask
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 724 | run . . . in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'lobHandlerDetector': 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 PoolableConnectionFactory (Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.)
->> 334 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 166 | run in java.util.concurrent.FutureTask
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 724 | run . . . in java.lang.Thread
Caused by MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.)
->> 334 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 166 | run in java.util.concurrent.FutureTask
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 724 | run . . . in java.lang.Thread
Caused by SQLNestedException: Cannot create PoolableConnectionFactory (Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.)
->> 1549 | createPoolableConnectionFactory in org.apache.commons.dbcp.BasicDataSource
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1388 | createDataSource in ''
| 1044 | getConnection in ''
| 334 | innerRun in java.util.concurrent.FutureTask$Sync
| 166 | run . . . in java.util.concurrent.FutureTask
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 724 | run in java.lang.Thread
Caused by CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
->> 409 | handleNewInstance in com.mysql.jdbc.Util
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1118 | createCommunicationsException in com.mysql.jdbc.SQLError
| 343 | <init> . in com.mysql.jdbc.MysqlIO
| 2308 | connectOneTryOnly in com.mysql.jdbc.ConnectionImpl
| 2122 | createNewIO in ''
| 774 | <init> in ''
| 49 | <init> . in com.mysql.jdbc.JDBC4Connection
| 409 | handleNewInstance in com.mysql.jdbc.Util
| 375 | getInstance in com.mysql.jdbc.ConnectionImpl
| 289 | connect in com.mysql.jdbc.NonRegisteringDriver
| 38 | createConnection in org.apache.commons.dbcp.DriverConnectionFactory
| 582 | makeObject in org.apache.commons.dbcp.PoolableConnectionFactory
| 1556 | validateConnectionFactory in org.apache.commons.dbcp.BasicDataSource
| 1545 | createPoolableConnectionFactory in ''
| 1388 | createDataSource in ''
| 1044 | getConnection in ''
| 334 | innerRun in java.util.concurrent.FutureTask$Sync
| 166 | run in java.util.concurrent.FutureTask
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 724 | run . . . in java.lang.Thread
Caused by ConnectException: Connection refused: connect
->> 79 | socketConnect in java.net.DualStackPlainSocketImpl
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 339 | doConnect in java.net.AbstractPlainSocketImpl
| 200 | connectToAddress in ''
| 182 | connect in ''
| 172 | connect . in java.net.PlainSocketImpl
| 392 | connect in java.net.SocksSocketImpl
| 579 | connect . in java.net.Socket
| 528 | connect in ''
| 425 | <init> . in ''
| 241 | <init> in ''
| 256 | connect . in com.mysql.jdbc.StandardSocketFactory
| 292 | <init> in com.mysql.jdbc.MysqlIO
| 2308 | connectOneTryOnly in com.mysql.jdbc.ConnectionImpl
| 2122 | createNewIO in ''
| 774 | <init> . in ''
| 49 | <init> in com.mysql.jdbc.JDBC4Connection
| 409 | handleNewInstance in com.mysql.jdbc.Util
| 375 | getInstance in com.mysql.jdbc.ConnectionImpl
| 289 | connect . in com.mysql.jdbc.NonRegisteringDriver
| 38 | createConnection in org.apache.commons.dbcp.DriverConnectionFactory
| 582 | makeObject in org.apache.commons.dbcp.PoolableConnectionFactory
| 1556 | validateConnectionFactory in org.apache.commons.dbcp.BasicDataSource
| 1545 | createPoolableConnectionFactory in ''
| 1388 | createDataSource in ''
| 1044 | getConnection in ''
| 334 | innerRun in java.util.concurrent.FutureTask$Sync
| 166 | run . . . in java.util.concurrent.FutureTask
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 724 | run in java.lang.Thread
I have tried all the available solutions from stack-overflow and other websites.
Till now I've been following the solutions available on
http://docs.grails.org/latest/guide/single.html#dataSource
Access MySQL server from Grails
and a few other links which I am not able to post here due to less reputation on stack-overflow.
I have done exactly the same that has been asked to be done on all of the solutions available in the above mentioned links. Still I am having the same error. I am not sure what I am missing out on. Not even sure if this is caused due to the VPN connection or something.
Please help me.
The issue got resolved finally.
I checked the MySQL conf file my.cnf in the server location ./etc/mysql/ . In the file my.cnf, under [mysqld] section, bind-address is set to 127.0.0.1. Instead of skip-networking being set to True, the default is now to listen only on localhost for all mysql ubuntu installations in order to avoid other servers connecting to mySQL.
Hence I commented out the line, setting bind-address=127.0.0.1 in the file my.cnf in ./etc/mysql/ folder and restarted the mysql and it worked like a charm!
Sometime when we have layer e.g docker, firewell, or proxy then these type of error comes which are harder to troubleshoot. I have faced similary type of error. I just solved this issue by bind the server with '0.0.0.0' instead of 'localhost' or '127.0.0.1'. by using this. etc/host will expose the server binding to all interfaces. and then i checked that the IP for localhost by using 'ifconfig' command. then used that IP to my internal archtecture docker application. thats works fine.
When I run my Grails app and I get the following error
| Loading Grails 2.3.5
| Configuring classpath
| Configuring classpath.
| Environment set to development
| Environment set to development.
| Environment set to development..
| Environment set to development...
| Environment set to development....
| Environment set to development.....
| Packaging Grails application
| Packaging Grails application.
| Packaging Grails application..
| Packaging Grails application...
| Packaging Grails application....
| Packaging Grails application.....
| Compiling 1 source files
| Compiling 1 source files.
| Compiling 1 source files..
| Compiling 1 source files...
| Compiling 1 source files....
| Compiling 1 source files.....
| Running Grails application
| Error 2015-04-21 11:54:24,947 [localhost-startStop-1] ERROR pool.ConnectionPool - Unable to create initial connections of pool .
Message: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
Line | Method
->> 411 | handleNewInstance in com.mysql.jdbc.Util
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1121 | createCommunicationsException in com.mysql.jdbc.SQLError
| 676 | readPacket . . . . . . . . . in com.mysql.jdbc.MysqlIO
| 1088 | doHandshake in ''
| 2493 | coreConnect . . . . . . . . . in com.mysql.jdbc.ConnectionImpl
| 2526 | connectOneTryOnly in ''
| 2311 | createNewIO . . . . . . . . . in ''
| 834 | <init> in ''
| 47 | <init> . . . . . . . . . . . in com.mysql.jdbc.JDBC4Connection
| 411 | handleNewInstance in com.mysql.jdbc.Util
| 416 | getInstance . . . . . . . . . in com.mysql.jdbc.ConnectionImpl
| 347 | connect in com.mysql.jdbc.NonRegisteringDriver
| 262 | run . . . . . . . . . . . . . in java.util.concurrent.FutureTask
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . . . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run in java.lang.Thread
Caused by EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpecte dly>
>->> 3166 | readFully in com.mysql.jdbc.MysqlIO>- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - >| 600 | readPacket in ''
| 1088 | doHandshake . . . . . . . . . in ''
| 2493 | coreConnect in com.mysql.jdbc.ConnectionImpl
| 2526 | connectOneTryOnly . . . . . . in ''
| 2311 | createNewIO in ''
| 834 | <init> . . . . . . . . . . . in ''
| 47 | <init> in com.mysql.jdbc.JDBC4Connection
| 411 | handleNewInstance . . . . . . in com.mysql.jdbc.Util
| 416 | getInstance in com.mysql.jdbc.ConnectionImpl
| 347 | connect . . . . . . . . . . . in com.mysql.jdbc.NonRegisteringDriver
| 262 | run in java.util.concurrent.FutureTask
| 1145 | runWorker . . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor
| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run . . . . . . . . . . . . . in java.lang.Thread
| Error 2015-04-21 11:54:25,051 [localhost-startStop-1] ERROR pool.ConnectionPool - Unable to create initial connections of pool .
Message: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
Line | Method
->> 411 | handleNewInstance in com.mysql.jdbc.Util
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1121 | createCommunicationsException in com.mysql.jdbc.SQLError
| 676 | readPacket . . . . . . . . . in com.mysql.jdbc.MysqlIO
| 1088 | doHandshake in ''
| 2493 | coreConnect . . . . . . . . . in com.mysql.jdbc.ConnectionImpl
| 2526 | connectOneTryOnly in ''
| 2311 | createNewIO . . . . . . . . . in ''
| 834 | <init> in ''
| 47 | <init> . . . . . . . . . . . in com.mysql.jdbc.JDBC4Connection
| 411 | handleNewInstance in com.mysql.jdbc.Util
| 416 | getInstance . . . . . . . . . in com.mysql.jdbc.ConnectionImpl
| 347 | connect in com.mysql.jdbc.NonRegisteringDriver
| 262 | run . . . . . . . . . . . . . in java.util.concurrent.FutureTask
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . . . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run in java.lang.Thread
Caused by EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpecte dly>
>->> 3166 | readFully in com.mysql.jdbc.MysqlIO>- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - >| 600 | readPacket in ''
| 1088 | doHandshake . . . . . . . . . in ''
| 2493 | coreConnect in com.mysql.jdbc.ConnectionImpl
| 2526 | connectOneTryOnly . . . . . . in ''
| 2311 | createNewIO in ''
| 834 | <init> . . . . . . . . . . . in ''
| 47 | <init> in com.mysql.jdbc.JDBC4Connection
| 411 | handleNewInstance . . . . . . in com.mysql.jdbc.Util
| 416 | getInstance in com.mysql.jdbc.ConnectionImpl
| 347 | connect . . . . . . . . . . . in com.mysql.jdbc.NonRegisteringDriver
| 262 | run in java.util.concurrent.FutureTask
| 1145 | runWorker . . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor
| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run . . . . . . . . . . . . . in java.lang.Thread
| Error 2015-04-21 11:54:25,139 [localhost-startStop-1] ERROR pool.ConnectionPool - Unable to create initial connections of pool .
Message: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
Line | Method
->> 411 | handleNewInstance in com.mysql.jdbc.Util
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1121 | createCommunicationsException in com.mysql.jdbc.SQLError
| 676 | readPacket . . . . . . . . . in com.mysql.jdbc.MysqlIO
| 1088 | doHandshake in ''
| 2493 | coreConnect . . . . . . . . . in com.mysql.jdbc.ConnectionImpl
| 2526 | connectOneTryOnly in ''
| 2311 | createNewIO . . . . . . . . . in ''
| 834 | <init> in ''
| 47 | <init> . . . . . . . . . . . in com.mysql.jdbc.JDBC4Connection
| 411 | handleNewInstance in com.mysql.jdbc.Util
| 416 | getInstance . . . . . . . . . in com.mysql.jdbc.ConnectionImpl
| 347 | connect in com.mysql.jdbc.NonRegisteringDriver
| 262 | run . . . . . . . . . . . . . in java.util.concurrent.FutureTask
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . . . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run in java.lang.Thread
Caused by EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpecte dly>
>->> 3166 | readFully in com.mysql.jdbc.MysqlIO>- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - >| 600 | readPacket in ''
| 1088 | doHandshake . . . . . . . . . in ''
| 2493 | coreConnect in com.mysql.jdbc.ConnectionImpl
| 2526 | connectOneTryOnly . . . . . . in ''
| 2311 | createNewIO in ''
| 834 | <init> . . . . . . . . . . . in ''
| 47 | <init> in com.mysql.jdbc.JDBC4Connection
| 411 | handleNewInstance . . . . . . in com.mysql.jdbc.Util
| 416 | getInstance in com.mysql.jdbc.ConnectionImpl
| 347 | connect . . . . . . . . . . . in com.mysql.jdbc.NonRegisteringDriver
| 262 | run in java.util.concurrent.FutureTask
| 1145 | runWorker . . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor
| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run . . . . . . . . . . . . . in java.lang.Thread
| Error 2015-04-21 11:54:25,169 [localhost-startStop-1] ERROR context.GrailsContextLoader - Error initializing the application: Err>
>The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. >Message: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org .spr
>The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. > Line | Method>->> 262 | run in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFac tor>
>The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. >->> 262 | run in java.util.concurrent.FutureTask>- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'lobHandlerDete cto>
>The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. >->> 262 | run in java.util.concurrent.FutureTask>- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'lobHandlerDetector': Invocation of init method failed; nested exc ept>
>The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. >->> 262 | run in java.util.concurrent.FutureTask>- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run in java.lang.Thread
Caused by MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is com.mysql.jdbc.exceptions.jdbc4.C omm>
>The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. >->> 262 | run in java.util.concurrent.FutureTask>- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run in java.lang.Thread
Caused by CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
->> 411 | handleNewInstance in com.mysql.jdbc.Util
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1121 | createCommunicationsException in com.mysql.jdbc.SQLError
| 676 | readPacket in com.mysql.jdbc.MysqlIO
| 1088 | doHandshake in ''
| 2493 | coreConnect in com.mysql.jdbc.ConnectionImpl
| 2526 | connectOneTryOnly in ''
| 2311 | createNewIO in ''
| 834 | <init> in ''
| 47 | <init> . in com.mysql.jdbc.JDBC4Connection
| 411 | handleNewInstance in com.mysql.jdbc.Util
| 416 | getInstance in com.mysql.jdbc.ConnectionImpl
| 347 | connect in com.mysql.jdbc.NonRegisteringDriver
| 262 | run . . . in java.util.concurrent.FutureTask
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run in java.lang.Thread
Caused by EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpecte dly>
>->> 3166 | readFully in com.mysql.jdbc.MysqlIO>- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 600 | readPacket in ''
| 1088 | doHandshake in ''
| 2493 | coreConnect in com.mysql.jdbc.ConnectionImpl
| 2526 | connectOneTryOnly in ''
| 2311 | createNewIO in ''
| 834 | <init> . in ''
| 47 | <init> in com.mysql.jdbc.JDBC4Connection
| 411 | handleNewInstance in com.mysql.jdbc.Util
| 416 | getInstance in com.mysql.jdbc.ConnectionImpl
| 347 | connect . in com.mysql.jdbc.NonRegisteringDriver
| 262 | run in java.util.concurrent.FutureTask
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run . . . in java.lang.Thread
| Error Forked Grails VM exited with error
| Server running. Browse to http://localhost:8080/TestDebug
and my code is the following:
dataSource {
pooled = true
driverClassName = "org.h2.Driver"
username = "sa"
password = ""
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = false
cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory' // Hibernate 3
// cache.region.factory_class = 'org.hibernate.cache.ehcache.EhCacheRegionFactory' // Hibernate 4
}
// environment specific settings
environments {
development {
dataSource {
dbCreate = "update"
url = "jdbc:mysql://localhost/nuage_v3"
driverClassName = "com.mysql.jdbc.Driver"
dialect = org.hibernate.dialect.MySQL5InnoDBDialect
username = "root"
password = "root"
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:h2:prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
properties {
maxActive = -1
minEvictableIdleTimeMillis=1800000
timeBetweenEvictionRunsMillis=1800000
numTestsPerEvictionRun=3
testOnBorrow=true
testWhileIdle=true
testOnReturn=false
validationQuery="SELECT 1"
jdbcInterceptors="ConnectionState"
}
}
}
}
The user and password are both correct, I tried reinstalling MySQL.
I've given up on trying to solve the problem.
I reinstalled grails and mysql on a diffenrent machine and it seems to work.
sorry to have bothered you all.
Thank you.
Problem is Mysql is not running.First run apache and Mysql then run grails app.Hope it will works .Also check 80 port is free or not if not then free your 80 port.
The same problem.. All of a sudden..
MySQLWorkbench works well, but grails "Unable to create initial connections of pool"
I've been spend half a day trying to fix this, searching answers. But nothing work for me..
Using Grails Database Migration Plugin 1.4 I want have the following structure of my existing database:
class StickerGroup {
}
Now I added the class Company and updated the class StickerGroup:
class StickerGroup {
static constraints = { company nullable: true, unique: true }
static belongsTo = [company: Company]
}
class Company {
static hasOne = [stickerGroup: StickerGroup]
}
I created the migration file and then I perform grails dbm-update. After that I get the following error log:
2015-01-20 15:03:49,549 [main] ERROR liquibase - Change Set 2015-01-20-update-Company.groovy::1421762562430-2::mg (generated) failed. Error: Error executing SQL ALTER TABLE `sticker_group` ADD `company_id` VARCHAR(10) NOT NULL UNIQUE: Duplicate entry '' for key 'company_id'
Message: Error executing SQL ALTER TABLE `sticker_group` ADD `company_id` VARCHAR(10) NOT NULL UNIQUE: Duplicate entry '' for key 'company_id'
Line | Method
->> 62 | execute in liquibase.executor.jvm.JdbcExecutor
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 104 | execute in ''
| 1091 | execute . . . . . in liquibase.database.AbstractDatabase
| 1075 | executeStatements in ''
| 317 | execute . . . . . in liquibase.changelog.ChangeSet
| 27 | visit in liquibase.changelog.visitor.UpdateVisitor
| 58 | run . . . . . . . in liquibase.changelog.ChangeLogIterator
| 114 | update in liquibase.Liquibase
| 26 | doCall . . . . . in DbmUpdate$_run_closure1_closure2
| 59 | doCall in _DatabaseMigrationCommon_groovy$_run_closure2_closure11
| 133 | executeInSession in grails.plugin.databasemigration.MigrationUtils
| 51 | doCall in _DatabaseMigrationCommon_groovy$_run_closure2
^ 25 | doCall . . . . . in DbmUpdate$_run_closure1
Caused by MySQLIntegrityConstraintViolationException: Duplicate entry '' for key 'company_id'
->> 377 | handleNewInstance in com.mysql.jdbc.Util
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 360 | getInstance in ''
| 971 | createSQLException in com.mysql.jdbc.SQLError
| 3887 | checkErrorPacket in com.mysql.jdbc.MysqlIO
| 3823 | checkErrorPacket in ''
| 2435 | sendCommand in ''
| 2582 | sqlQueryDirect . in ''
| 2526 | execSQL in com.mysql.jdbc.ConnectionImpl
| 2484 | execSQL . . . . . in ''
| 848 | execute in com.mysql.jdbc.StatementImpl
| 742 | execute . . . . . in ''
| 92 | doInStatement in liquibase.executor.jvm.JdbcExecutor$1ExecuteStatementCallback
| 55 | execute . . . . . in liquibase.executor.jvm.JdbcExecutor
| 104 | execute in ''
| 1091 | execute . . . . . in liquibase.database.AbstractDatabase
| 1075 | executeStatements in ''
| 317 | execute . . . . . in liquibase.changelog.ChangeSet
| 27 | visit in liquibase.changelog.visitor.UpdateVisitor
| 58 | run . . . . . . . in liquibase.changelog.ChangeLogIterator
| 114 | update in liquibase.Liquibase
| 26 | doCall . . . . . in DbmUpdate$_run_closure1_closure2
| 59 | doCall in _DatabaseMigrationCommon_groovy$_run_closure2_closure11
| 133 | executeInSession in grails.plugin.databasemigration.MigrationUtils
| 51 | doCall in _DatabaseMigrationCommon_groovy$_run_closure2
^ 25 | doCall . . . . . in DbmUpdate$_run_closure1
liquibase.exception.MigrationFailedException: Migration failed for change set 2015-01-20-update-Company.groovy::1421762562430-2::mg (generated):
Reason: liquibase.exception.DatabaseException: Error executing SQL ALTER TABLE `sticker_group` ADD `company_id` VARCHAR(10) NOT NULL UNIQUE: Duplicate entry '' for key 'company_id':
Caused By: Error executing SQL ALTER TABLE `sticker_group` ADD `company_id` VARCHAR(10) NOT NULL UNIQUE: Duplicate entry '' for key 'company_id':
Caused By: Duplicate entry '' for key 'company_id'
at liquibase.changelog.ChangeSet.execute(ChangeSet.java:347)
at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:27)
at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:58)
at liquibase.Liquibase.update(Liquibase.java:114)
at DbmUpdate$_run_closure1_closure2.doCall(DbmUpdate:26)
at _DatabaseMigrationCommon_groovy$_run_closure2_closure11.doCall(_DatabaseMigrationCommon_groovy:59)
at grails.plugin.databasemigration.MigrationUtils.executeInSession(MigrationUtils.groovy:133)
at _DatabaseMigrationCommon_groovy$_run_closure2.doCall(_DatabaseMigrationCommon_groovy:51)
at DbmUpdate$_run_closure1.doCall(DbmUpdate:25)
Caused by: liquibase.exception.DatabaseException: Error executing SQL ALTER TABLE `sticker_group` ADD `company_id` VARCHAR(10) NOT NULL UNIQUE: Duplicate entry '' for key 'company_id'
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:62)
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:104)
at liquibase.database.AbstractDatabase.execute(AbstractDatabase.java:1091)
at liquibase.database.AbstractDatabase.executeStatements(AbstractDatabase.java:1075)
at liquibase.changelog.ChangeSet.execute(ChangeSet.java:317)
... 8 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '' for key 'company_id'
at com.mysql.jdbc.Util.handleNewInstance(Util.java:377)
at com.mysql.jdbc.Util.getInstance(Util.java:360)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:971)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3887)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3823)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2435)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2582)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2526)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2484)
at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:848)
at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:742)
at liquibase.executor.jvm.JdbcExecutor$1ExecuteStatementCallback.doInStatement(JdbcExecutor.java:92)
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:55)
... 12 more
How can I fix this error?
I have the following two simple models creating a bidirectional one-to-many relationship in a Grails 2.4.3 application:
class Player {
String firstName
String lastName
String position
static belongsTo = [team: Team]
}
class Team {
String name
List players = new ArrayList()
static hasMany = [players: Player]
static mapping= {
players cascade:"all-delete-orphan"
}
}
I would like to be able to save and update teams and their associated players via nested JSON, like so:
{
name : "team A",
players : [
{
firstName : "john",
lastName :"doe",
position : "center"
}
]
}
My TeamController save action looks like this:
def save() {
def team = new Team(request.JSON)
team.save()
respond team
}
When I make a request with that JSON, I get an error:
curl -X POST -d '{name:"team a",players:[{firstName:"john",lastName:"doe",position:"center"}]}' http://localhost:8080/team-test/team/save.json --header "Content-Type:application/json"
Produces this output in console:
| Error 2014-11-14 10:32:26,111 [http-bio-8080-exec-6] ERROR errors.GrailsExceptionResolver - NullPointerException occurred when processing request: [POST] /team-test/team/save.json
Stacktrace follows:
Message: null
Line | Method
->> 8 | save in team.test.TeamController$$EOvbjH0K
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 198 | doFilter in grails.plugin.cache.web.filter.PageFragmentCachingFilter
| 63 | doFilter in grails.plugin.cache.web.filter.AbstractFilter
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run in java.lang.Thread
Because that's a rather vague message, I put a try/catch around the team.save() call in the TeamController and print out the stack trace:
def save() {
def team = new Team(request.JSON)
try {
team.save()
}
catch(Exception e)
{
e.printStackTrace()
}
respond team
}
Error java.lang.NullPointerException
| Error at org.hibernate.engine.spi.BatchFetchQueue.removeBatchLoadableEntityKey(BatchFetchQueue.java:163)
| Error at org.hibernate.engine.internal.StatefulPersistenceContext.addEntity(StatefulPersistenceContext.java:388)
| Error at org.hibernate.engine.internal.StatefulPersistenceContext.addEntity(StatefulPersistenceContext.java:461)
| Error at org.hibernate.action.internal.AbstractEntityInsertAction.makeEntityManaged(AbstractEntityInsertAction.java:143)
| Error at org.hibernate.engine.spi.ActionQueue.addResolvedEntityInsertAction(ActionQueue.java:201)
| Error at org.hibernate.engine.spi.ActionQueue.addInsertAction(ActionQueue.java:179)
| Error at org.hibernate.engine.spi.ActionQueue.addAction(ActionQueue.java:214)
| Error at org.hibernate.event.internal.AbstractSaveEventListener.addInsertAction(AbstractSaveEventListener.java:324)
| Error at org.hibernate.event.internal.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:288)
| Error at org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:194)
| Error at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:125)
| Error at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:209)
| Error at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:194)
| Error at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:114)
| Error at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:90)
| Error at org.hibernate.internal.SessionImpl.fireSaveOrUpdate(SessionImpl.java:684)
| Error at org.hibernate.internal.SessionImpl.saveOrUpdate(SessionImpl.java:676)
| Error at org.hibernate.engine.spi.CascadingActions$5.cascade(CascadingActions.java:235)
| Error at org.hibernate.engine.internal.Cascade.cascadeToOne(Cascade.java:350)
| Error at org.hibernate.engine.internal.Cascade.cascadeAssociation(Cascade.java:293)
| Error at org.hibernate.engine.internal.Cascade.cascadeProperty(Cascade.java:161)
| Error at org.hibernate.engine.internal.Cascade.cascadeCollectionElements(Cascade.java:379)
| Error at org.hibernate.engine.internal.Cascade.cascadeCollection(Cascade.java:319)
| Error at org.hibernate.engine.internal.Cascade.cascadeAssociation(Cascade.java:296)
| Error at org.hibernate.engine.internal.Cascade.cascadeProperty(Cascade.java:161)
| Error at org.hibernate.engine.internal.Cascade.cascade(Cascade.java:118)
| Error at org.hibernate.event.internal.AbstractSaveEventListener.cascadeAfterSave(AbstractSaveEventListener.java:460)
| Error at org.hibernate.event.internal.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:294)
| Error at org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:194)
| Error at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:125)
| Error at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:209)
| Error at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:194)
| Error at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:114)
| Error at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:90)
| Error at org.hibernate.internal.SessionImpl.fireSaveOrUpdate(SessionImpl.java:684)
| Error at org.hibernate.internal.SessionImpl.saveOrUpdate(SessionImpl.java:676)
| Error at org.hibernate.internal.SessionImpl.saveOrUpdate(SessionImpl.java:671)
| Error at org.codehaus.groovy.grails.orm.hibernate.metaclass.SavePersistentMethod$1.doInHibernate(SavePersistentMethod.java:58)
| Error at org.codehaus.groovy.grails.orm.hibernate.GrailsHibernateTemplate.doExecute(GrailsHibernateTemplate.java:179)
| Error at org.codehaus.groovy.grails.orm.hibernate.GrailsHibernateTemplate.execute(GrailsHibernateTemplate.java:123)
| Error at org.codehaus.groovy.grails.orm.hibernate.metaclass.SavePersistentMethod.performSave(SavePersistentMethod.java:56)
| Error at org.codehaus.groovy.grails.orm.hibernate.metaclass.AbstractSavePersistentMethod.doInvokeInternal(AbstractSavePersistentMethod.java:215)
| Error at org.codehaus.groovy.grails.orm.hibernate.metaclass.AbstractDynamicPersistentMethod.invoke(AbstractDynamicPersistentMethod.java:68)
| Error at org.codehaus.groovy.grails.orm.hibernate.HibernateGormInstanceApi.save(HibernateGormInstanceApi.groovy:156)
| Error at team.test.Team$$EOvbjH0K.save(Team.groovy)
| Error at team.test.Team$$DOvbjH0K.save(Unknown Source)
| Error at team.test.Team.save(Team.groovy)
| Error at team.test.Team$save.call(Unknown Source)
| Error at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
| Error at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
| Error at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
| Error at team.test.TeamController$$EOvbkj0y.save(TeamController.groovy:9)
| Error at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| Error at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
| Error at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
| Error at java.lang.reflect.Method.invoke(Method.java:606)
| Error at org.springsource.loaded.ri.ReloadedTypeInvoker$2.invoke(ReloadedTypeInvoker.java:122)
| Error at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1299)
| Error at org.codehaus.groovy.grails.web.servlet.mvc.MixedGrailsControllerHelper.invoke(MixedGrailsControllerHelper.java:154)
| Error at org.codehaus.groovy.grails.web.servlet.mvc.AbstractGrailsControllerHelper.handleAction(AbstractGrailsControllerHelper.java:375)
| Error at org.codehaus.groovy.grails.web.servlet.mvc.AbstractGrailsControllerHelper.executeAction(AbstractGrailsControllerHelper.java:252)
| Error at org.codehaus.groovy.grails.web.servlet.mvc.AbstractGrailsControllerHelper.handleURI(AbstractGrailsControllerHelper.java:205)
| Error at org.codehaus.groovy.grails.web.servlet.mvc.AbstractGrailsControllerHelper.handleURI(AbstractGrailsControllerHelper.java:126)
| Error at org.codehaus.groovy.grails.web.servlet.mvc.SimpleGrailsController.handleRequest(SimpleGrailsController.java:72)
| Error at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:50)
| Error at org.codehaus.groovy.grails.web.servlet.GrailsDispatcherServlet.doDispatch(GrailsDispatcherServlet.java:347)
| Error at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870)
| Error at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
| Error at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:863)
| Error at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
| Error at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
| Error at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
| Error at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
| Error at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
| Error at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
| Error at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
| Error at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
| Error at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:198)
| Error at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
| Error at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
| Error at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
| Error at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
| Error at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
| Error at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101)
| Error at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
| Error at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
| Error at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101)
| Error at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
| Error at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
| Error at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101)
| Error at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
| Error at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
| Error at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:748)
| Error at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:486)
| Error at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:411)
| Error at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:338)
| Error at org.codehaus.groovy.grails.web.mapping.UrlMappingUtils.forwardRequestForUrlMappingInfo(UrlMappingUtils.java:178)
| Error at org.codehaus.groovy.grails.web.mapping.UrlMappingUtils.forwardRequestForUrlMappingInfo(UrlMappingUtils.java:144)
| Error at org.codehaus.groovy.grails.web.mapping.UrlMappingUtils.forwardRequestForUrlMappingInfo(UrlMappingUtils.java:135)
| Error at org.codehaus.groovy.grails.web.mapping.filter.UrlMappingsFilter.doFilterInternal(UrlMappingsFilter.java:216)
| Error at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
| Error at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
| Error at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
| Error at org.codehaus.groovy.grails.web.servlet.mvc.GrailsWebRequestFilter.doFilterInternal(GrailsWebRequestFilter.java:69)
| Error at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
| Error at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
| Error at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
| Error at org.codehaus.groovy.grails.web.filters.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:67)
| Error at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
| Error at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
| Error at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
| Error at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
| Error at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
| Error at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
| Error at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
| Error at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
| Error at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
| Error at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
| Error at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
| Error at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
| Error at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
| Error at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
| Error at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
| Error at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
| Error at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
| Error at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)
| Error at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
| Error at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
| Error at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
| Error at java.lang.Thread.run(Thread.java:745)
For further investigation, I put some logging in the controller action to see what's going on within the object:
def save() {
JSON.use('deep')
def team = new Team(request.JSON)
println "errors? " + team.getErrors()
println "team: " + team.toString()
println ((team as JSON).toString())
respond team
}
which produces the following output:
errors? grails.validation.ValidationErrors: 0 errors
team: team.test.Team : (unsaved)
{
"class":"team.test.Team",
"id":null,
"name":"team a",
"players":[
{
"class":"team.test.Player",
"id":null,
"firstName":"john",
"lastName":"doe",
"position":"center",
"team":null
}
]
}
Is there something wrong with my JSON? Why do I get this error? Is it because the team reference is null in the player object? Why is the team reference null in the player object?
Out of curiosity, I removed the belongsTo property from the Player class, and things work as expected...
{"class":"team.test.Team","id":2,"name":"team a","players":[{"class":"team.test.Player","id":2}]}
Why does it not work in the bidirectional case? What are the different implications of bidirectional and unidirectional in terms of table relationships, data binding, etc? I understand the different cascade strategies when using belongsTo or not in a one-to-many relationship, but both should cascade saves I thought.
I know I'm asking many questions. I need help making this work but would also like to understand what is happening in principle. Help is much appreciated.
edit:
per #th3morg's suggestion I attempted manually building out the Team and Player models and associating them via Team.addToPlayers().
def save() {
JSON.use('deep')
def teamData = request.JSON
def team = new Team()
team.name = teamData.name
teamData.players.each { playerData ->
def player = new Player(playerData)
team.addToPlayers(player)
}
team.save()
println ((team as JSON).toString())
respond team
}
produces:
{"class":"team.test.Team","id":3,"name":"team a","players":[{"class":"team.test.Player","id":3,"firstName":"john","lastName":"doe","position":"center","team":{"_ref":"../..","class":"team.test.Team"}}]}
This appears to work, but it is verbose and fragile. Is there no way to achieve the same result through automatic binding or through some other conventional magic?
I think in your case, the reason is straightforward - you need to explicitly call team.addToPlayers(player) before you save. I'm guessing that instantiating a team with the JSON constructor is equivalent to the Map constructor, which is basically equivalent to doing the following:
def team = new Team()
team.players = [new Player(), new Player()]
team.save()
i.e. setting the players properly directly, rather than calling addToPlayers.
If you run this in a test app, you will get exactly the same exception as you received in your version. This is because (as you've recognized), each Player does not have a back-reference to the Team set (which is what team.addToPlayers()) does. This (strangely) still saves the player object because the Hibernate session flushes when the controller finishes, saving any unsaved instances.
I'd be surprised if removing belongsTo property from the Player class actually fixes the issue - did it actually persist the TeamPlayers relationship? Or did it just look like it worked because you were responding with a JSON object where you had effectively manually set the players property?
I realize this is over a year old now, but the reason why I'm commenting is to leave a note for others : there is a (possibly related) known Grails bug which throws the same exception with multiple cascading relationships (e.g. A -> hasMany -> B hasMany -> C) where a child/grandchild has a beforeInsert() or beforeUpdate() method. This may be fixed in Grails 3.x but looks like it will not be fixed in 2.x. - see here and here.
You may be able to fix this with a beforeSave() function within your Team domain where you iterate over the players and save each player. This should avoid hibernate trying to save the transient player objects and also prevent you from having to code it yourself in the controller, which is a bit odd feeling.
Also, using GSON, you might be able to avoid any of the addTo associations hibernate would want.
https://github.com/robfletcher/grails-gson#readme
I have switched from Grails 2.2.4 to Grails 2.4.3 and experienced bad problems with my IntelliJ IDEA 13.1.4 IDE.
After creating a clean Grails 2.4.3 project and adding a clean controller class I start the project via "run-app" in IntelliJ IDEA. Afterwards I change something in the controller and I get the following exceptions:
2014-09-29 18:45:41,801 [Thread-11] ERROR plugins.AbstractGrailsPluginManager - Plugin
[controllers:2.4.3] could not reload changes to file [D:\VS\Eclipse Workspace\xx\grails-app\controllers\com\xx\backoffice\MaintenanceController.groovy]: Cannot get property 'cacheOperationSource' on null object
Message: Cannot get property 'cacheOperationSource' on null object
Line | Method
->> 184 | doCall in CacheGrailsPlugin$_closure4
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
.....................Error
|
2014-09-29 18:45:43,276 [FileSystemWatcher: files=#175 cl=groovy.lang.GroovyClassLoader#177f04d9] ERROR agent.Watcher - FileWatcher caught serious error, see cause
Message: loader (instance of org/springsource/loaded/ChildClassLoader): attempted duplicate class definition for name: "com/xx/MaintenanceController$$DOrGoSVQ"
Line | Method
->> 791 | defineClass in java.lang.ClassLoader
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 634 | defineClass in ''
^ 722 | run . . . . in java.lang.Thread
My BuildConfig.groovy:
grails.servlet.version = "3.0" // Change depending on target container compliance (2.5 or 3.0)
grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
grails.project.work.dir = "target/work"
grails.project.target.level = 1.6
grails.project.source.level = 1.6
//grails.project.war.file = "target/${appName}-${appVersion}.war"
grails.reload.enabled = true
forkConfig = [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false]
grails.project.fork = [
// configure settings for compilation JVM, note that if you alter the Groovy version forked compilation is required
// compile: [maxMemory: 256, minMemory: 64, debug: false, maxPerm: 256, daemon:true],
// configure settings for the test-app JVM, uses the daemon by default
test: forkConfig,
// configure settings for the run-app JVM
run: forkConfig,
// configure settings for the run-war JVM
war: forkConfig,
// configure settings for the Console UI JVM
console: forkConfig
]
grails.project.dependency.resolver = "maven" // or ivy
grails.dependency.cache.dir = "${userHome}/.m2/repository"
grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
// specify dependency exclusions here; for example, uncomment this to disable ehcache:
// excludes 'ehcache'
}
log "info" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
checksums true // Whether to verify checksums on resolve
legacyResolve false // whether to do a secondary resolve on plugin installation, not advised and here for backwards compatibility
repositories {
inherits true // Whether to inherit repository definitions from plugins
grailsPlugins()
grailsHome()
mavenLocal()
grailsCentral()
mavenCentral()
// uncomment these (or add new ones) to enable remote dependency resolution from public Maven repositories
mavenRepo "http://repository.codehaus.org"
//mavenRepo "http://download.java.net/maven/2/"
//mavenRepo "http://repository.jboss.com/maven2/"
}
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes e.g.
// runtime 'mysql:mysql-connector-java:5.1.29'
// runtime 'org.postgresql:postgresql:9.3-1101-jdbc41'
test "org.grails:grails-datastore-test-support:1.0-grails-2.4"
runtime 'mysql:mysql-connector-java:5.1.32'
}
plugins {
// plugins for the build system only
build ":tomcat:7.0.55"
// plugins for the compile step
compile ":scaffolding:2.1.2"
compile ':cache:1.1.8'
compile ":asset-pipeline:1.9.6"
compile ":shiro:1.2.1"
compile ":less-asset-pipeline:1.10.0"
compile ":jquery-ui:1.10.4"
// plugins needed at runtime but not for compilation
runtime ":hibernate4:4.3.5.5" // or
//runtime ":hibernate:3.6.10.17"
runtime ":database-migration:1.4.0"
runtime ":jquery:1.11.1"
// Uncomment these to enable additional asset-pipeline capabilities
//compile ":sass-asset-pipeline:1.9.0"
//compile ":less-asset-pipeline:1.10.0"
//compile ":coffee-asset-pipeline:1.8.0"
//compile ":handlebars-asset-pipeline:1.3.0.3"
}
}
I did some research and found out that I have to disable the forked mode as IDEA has problems with that. Therefor I disabled this feature in the BuildConfig.groovy with the grails.project.fork = false option.
Now I can't start the app via "run-app" because of the following exceptions:
2014-09-29 18:48:56,144 [localhost-startStop-1] ERROR pool.ConnectionPool - Unable to create initial connections of pool.
Message: java.lang.NoSuchMethodError: com.mysql.jdbc.StatementImpl.removeOpenResultSet(Ljava/sql/ResultSet;)V
Line | Method
->> 1094 | createSQLException in com.mysql.jdbc.SQLError
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 997 | createSQLException in ''
| 983 | createSQLException in ''
| 928 | createSQLException in ''
| 959 | createSQLException in ''
| 949 | createSQLException in ''
| 432 | handleNewInstance in com.mysql.jdbc.Util
| 419 | getInstance in com.mysql.jdbc.ConnectionImpl
| 344 | connect . . . . . in com.mysql.jdbc.NonRegisteringDriver
| 334 | innerRun in java.util.concurrent.FutureTask$Sync
| 166 | run . . . . . . . in java.util.concurrent.FutureTask
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run in java.lang.Thread
Caused by NoSuchMethodError: com.mysql.jdbc.StatementImpl.removeOpenResultSet(Ljava/sql/ResultSet;)V
->> 7467 | realClose in com.mysql.jdbc.ResultSetImpl
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 923 | close in ''
| 801 | convertShowWarningsToSQLWarnings in com.mysql.jdbc.SQLError
| 4445 | scanForAndThrowDataTruncation in com.mysql.jdbc.MysqlIO
| 2923 | sqlQueryDirect . . in ''
| 2820 | execSQL in com.mysql.jdbc.ConnectionImpl
| 2769 | execSQL . . . . . in ''
| 1569 | executeQuery in com.mysql.jdbc.StatementImpl
| 4210 | loadServerVariables in com.mysql.jdbc.ConnectionImpl
| 3604 | initializePropsFromServer in ''
| 2542 | connectOneTryOnly in ''
| 2309 | createNewIO in ''
| 834 | <init> . . . . . . in ''
| 46 | <init> in com.mysql.jdbc.JDBC4Connection
| 408 | handleNewInstance in com.mysql.jdbc.Util
| 419 | getInstance in com.mysql.jdbc.ConnectionImpl
| 344 | connect . . . . . in com.mysql.jdbc.NonRegisteringDriver
| 334 | innerRun in java.util.concurrent.FutureTask$Sync
| 166 | run . . . . . . . in java.util.concurrent.FutureTask
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run in java.lang.Thread
Error |
2014-09-29 18:48:56,203 [localhost-startStop-1] ERROR pool.ConnectionPool - Unable to create initial connections of pool.
Message: java.lang.NoSuchMethodError: com.mysql.jdbc.StatementImpl.removeOpenResultSet(Ljava/sql/ResultSet;)V
Line | Method
->> 1094 | createSQLException in com.mysql.jdbc.SQLError
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 997 | createSQLException in ''
| 983 | createSQLException in ''
| 928 | createSQLException in ''
| 959 | createSQLException in ''
| 949 | createSQLException in ''
| 432 | handleNewInstance in com.mysql.jdbc.Util
| 419 | getInstance in com.mysql.jdbc.ConnectionImpl
| 344 | connect . . . . . in com.mysql.jdbc.NonRegisteringDriver
| 334 | innerRun in java.util.concurrent.FutureTask$Sync
| 166 | run . . . . . . . in java.util.concurrent.FutureTask
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run in java.lang.Thread
Caused by NoSuchMethodError: com.mysql.jdbc.StatementImpl.removeOpenResultSet(Ljava/sql/ResultSet;)V
->> 7467 | realClose in com.mysql.jdbc.ResultSetImpl
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 923 | close in ''
| 801 | convertShowWarningsToSQLWarnings in com.mysql.jdbc.SQLError
| 4445 | scanForAndThrowDataTruncation in com.mysql.jdbc.MysqlIO
| 2923 | sqlQueryDirect . . in ''
| 2820 | execSQL in com.mysql.jdbc.ConnectionImpl
| 2769 | execSQL . . . . . in ''
| 1569 | executeQuery in com.mysql.jdbc.StatementImpl
| 4210 | loadServerVariables in com.mysql.jdbc.ConnectionImpl
| 3604 | initializePropsFromServer in ''
| 2542 | connectOneTryOnly in ''
| 2309 | createNewIO in ''
| 834 | <init> . . . . . . in ''
| 46 | <init> in com.mysql.jdbc.JDBC4Connection
| 408 | handleNewInstance in com.mysql.jdbc.Util
| 419 | getInstance in com.mysql.jdbc.ConnectionImpl
| 344 | connect . . . . . in com.mysql.jdbc.NonRegisteringDriver
| 334 | innerRun in java.util.concurrent.FutureTask$Sync
| 166 | run . . . . . . . in java.util.concurrent.FutureTask
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run in java.lang.Thread
Error |
2014-09-29 18:48:56,251 [localhost-startStop-1] ERROR pool.ConnectionPool - Unable to create initial connections of pool.
Message: java.lang.NoSuchMethodError: com.mysql.jdbc.StatementImpl.removeOpenResultSet(Ljava/sql/ResultSet;)V
Line | Method
->> 1094 | createSQLException in com.mysql.jdbc.SQLError
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 997 | createSQLException in ''
| 983 | createSQLException in ''
| 928 | createSQLException in ''
| 959 | createSQLException in ''
| 949 | createSQLException in ''
| 432 | handleNewInstance in com.mysql.jdbc.Util
| 419 | getInstance in com.mysql.jdbc.ConnectionImpl
| 344 | connect . . . . . in com.mysql.jdbc.NonRegisteringDriver
| 334 | innerRun in java.util.concurrent.FutureTask$Sync
| 166 | run . . . . . . . in java.util.concurrent.FutureTask
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run in java.lang.Thread
Caused by NoSuchMethodError: com.mysql.jdbc.StatementImpl.removeOpenResultSet(Ljava/sql/ResultSet;)V
->> 7467 | realClose in com.mysql.jdbc.ResultSetImpl
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 923 | close in ''
| 801 | convertShowWarningsToSQLWarnings in com.mysql.jdbc.SQLError
| 4445 | scanForAndThrowDataTruncation in com.mysql.jdbc.MysqlIO
| 2923 | sqlQueryDirect . . in ''
| 2820 | execSQL in com.mysql.jdbc.ConnectionImpl
| 2769 | execSQL . . . . . in ''
| 1569 | executeQuery in com.mysql.jdbc.StatementImpl
| 4210 | loadServerVariables in com.mysql.jdbc.ConnectionImpl
| 3604 | initializePropsFromServer in ''
| 2542 | connectOneTryOnly in ''
| 2309 | createNewIO in ''
| 834 | <init> . . . . . . in ''
| 46 | <init> in com.mysql.jdbc.JDBC4Connection
| 408 | handleNewInstance in com.mysql.jdbc.Util
| 419 | getInstance in com.mysql.jdbc.ConnectionImpl
| 344 | connect . . . . . in com.mysql.jdbc.NonRegisteringDriver
| 334 | innerRun in java.util.concurrent.FutureTask$Sync
| 166 | run . . . . . . . in java.util.concurrent.FutureTask
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run in java.lang.Thread
Error |
2014-09-29 18:48:56,269 [localhost-startStop-1] ERROR context.GrailsContextLoaderListener - 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': 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 java.sql.SQLException: java.lang.NoSuchMethodError: com.mysql.jdbc.StatementImpl.removeOpenResultSet(Ljava/sql/ResultSet;)V
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': 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 java.sql.SQLException: java.lang.NoSuchMethodError: com.mysql.jdbc.StatementImpl.removeOpenResultSet(Ljava/sql/ResultSet;)V
Line | Method
->> 334 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 166 | run in java.util.concurrent.FutureTask
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run . . . in java.lang.Thread
Caused by 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 java.sql.SQLException: java.lang.NoSuchMethodError: com.mysql.jdbc.StatementImpl.removeOpenResultSet(Ljava/sql/ResultSet;)V
->> 334 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 166 | run in java.util.concurrent.FutureTask
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run . . . in java.lang.Thread
Caused by 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 java.sql.SQLException: java.lang.NoSuchMethodError: com.mysql.jdbc.StatementImpl.removeOpenResultSet(Ljava/sql/ResultSet;)V
->> 334 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 166 | run in java.util.concurrent.FutureTask
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run . . . in java.lang.Thread
Caused by 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 java.sql.SQLException: java.lang.NoSuchMethodError: com.mysql.jdbc.StatementImpl.removeOpenResultSet(Ljava/sql/ResultSet;)V
->> 334 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 166 | run in java.util.concurrent.FutureTask
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run . . . in java.lang.Thread
Caused by 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 java.sql.SQLException: java.lang.NoSuchMethodError: com.mysql.jdbc.StatementImpl.removeOpenResultSet(Ljava/sql/ResultSet;)V
->> 334 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 166 | run in java.util.concurrent.FutureTask
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run . . . in java.lang.Thread
Caused by MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is java.sql.SQLException: java.lang.NoSuchMethodError: com.mysql.jdbc.StatementImpl.removeOpenResultSet(Ljava/sql/ResultSet;)V
->> 334 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 166 | run in java.util.concurrent.FutureTask
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run . . . in java.lang.Thread
Caused by SQLException: java.lang.NoSuchMethodError: com.mysql.jdbc.StatementImpl.removeOpenResultSet(Ljava/sql/ResultSet;)V
->> 1094 | createSQLException in com.mysql.jdbc.SQLError
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 997 | createSQLException in ''
| 983 | createSQLException in ''
| 928 | createSQLException in ''
| 959 | createSQLException in ''
| 949 | createSQLException in ''
| 432 | handleNewInstance in com.mysql.jdbc.Util
| 419 | getInstance in com.mysql.jdbc.ConnectionImpl
| 344 | connect . in com.mysql.jdbc.NonRegisteringDriver
| 334 | innerRun in java.util.concurrent.FutureTask$Sync
| 166 | run . . . in java.util.concurrent.FutureTask
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run in java.lang.Thread
Caused by NoSuchMethodError: com.mysql.jdbc.StatementImpl.removeOpenResultSet(Ljava/sql/ResultSet;)V
->> 7467 | realClose in com.mysql.jdbc.ResultSetImpl
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 923 | close in ''
| 801 | convertShowWarningsToSQLWarnings in com.mysql.jdbc.SQLError
| 4445 | scanForAndThrowDataTruncation in com.mysql.jdbc.MysqlIO
| 2923 | sqlQueryDirect in ''
| 2820 | execSQL in com.mysql.jdbc.ConnectionImpl
| 2769 | execSQL . in ''
| 1569 | executeQuery in com.mysql.jdbc.StatementImpl
| 4210 | loadServerVariables in com.mysql.jdbc.ConnectionImpl
| 3604 | initializePropsFromServer in ''
| 2542 | connectOneTryOnly in ''
| 2309 | createNewIO in ''
| 834 | <init> . in ''
| 46 | <init> in com.mysql.jdbc.JDBC4Connection
| 408 | handleNewInstance in com.mysql.jdbc.Util
| 419 | getInstance in com.mysql.jdbc.ConnectionImpl
| 344 | connect . in com.mysql.jdbc.NonRegisteringDriver
| 334 | innerRun in java.util.concurrent.FutureTask$Sync
| 166 | run . . . in java.util.concurrent.FutureTask
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run in java.lang.Thread
My DataSource.groovy:
dataSource {
pooled = true
jmxExport = true
driverClassName = "com.mysql.jdbc.Driver"
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = false
// cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory' // Hibernate 3
cache.region.factory_class = 'org.hibernate.cache.ehcache.EhCacheRegionFactory' // Hibernate 4
singleSession = true // configure OSIV singleSession mode
flush.mode = 'manual' // OSIV session flush mode outside of transactional context
reload = false
}
// environment specific settings
environments {
development {
dataSource {
pooled = true
dbCreate = "update"
url = "jdbc:mysql://localhost:3306/xxx?autoreconnect=true"
driverClassName = "com.mysql.jdbc.Driver"
properties {
// See http://grails.org/doc/latest/guide/conf.html#dataSource for documentation
jmxEnabled = true
initialSize = 5
maxActive = 50
minIdle = 5
maxIdle = 25
maxWait = 10000
maxAge = 10 * 60000
timeBetweenEvictionRunsMillis = 5000
minEvictableIdleTimeMillis = 60000
validationQuery = "SELECT 1"
validationQueryTimeout = 3
validationInterval = 15000
testOnBorrow = true
testWhileIdle = true
testOnReturn = false
jdbcInterceptors = "ConnectionState"
defaultTransactionIsolation = java.sql.Connection.TRANSACTION_READ_COMMITTED
}
username = ""
password = ""
}
}
test {
pooled = true
dbCreate = "update"
url = "jdbc:mysql://localhost:3306/xxx?autoreconnect=true"
driverClassName = "com.mysql.jdbc.Driver"
properties {
// See http://grails.org/doc/latest/guide/conf.html#dataSource for documentation
jmxEnabled = true
initialSize = 5
maxActive = 50
minIdle = 5
maxIdle = 25
maxWait = 10000
maxAge = 10 * 60000
timeBetweenEvictionRunsMillis = 5000
minEvictableIdleTimeMillis = 60000
validationQuery = "SELECT 1"
validationQueryTimeout = 3
validationInterval = 15000
testOnBorrow = true
testWhileIdle = true
testOnReturn = false
jdbcInterceptors = "ConnectionState"
defaultTransactionIsolation = java.sql.Connection.TRANSACTION_READ_COMMITTED
}
username = ""
password = ""
}
production {
dataSource {
pooled = true
dbCreate = "update"
url = "jdbc:mysql://localhost:3306/xxx?autoreconnect=true"
driverClassName = "com.mysql.jdbc.Driver"
properties {
// See http://grails.org/doc/latest/guide/conf.html#dataSource for documentation
jmxEnabled = true
initialSize = 5
maxActive = 50
minIdle = 5
maxIdle = 25
maxWait = 10000
maxAge = 10 * 60000
timeBetweenEvictionRunsMillis = 5000
minEvictableIdleTimeMillis = 60000
validationQuery = "SELECT 1"
validationQueryTimeout = 3
validationInterval = 15000
testOnBorrow = true
testWhileIdle = true
testOnReturn = false
jdbcInterceptors = "ConnectionState"
defaultTransactionIsolation = java.sql.Connection.TRANSACTION_READ_COMMITTED
}
username = ""
password = ""
}
}
}
Any idea how I could solve these problems?
Please take a look at this post: Grails 2.4.3 fails to reload controller or service
If it doesn´t help please provide your BuildConfig.groovy