Grails无法创建池的初始连接

时间:2015-04-21 10:15:38

标签: mysql grails

当我运行我的Grails应用程序时,我收到以下错误

| 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

我的代码如下:

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"
            }
        }
    }
}

用户和密码都正确,我尝试重新安装MySQL。

3 个答案:

答案 0 :(得分:0)

我已经放弃了尝试解决问题的方法。 我在一台不同的机器上重新安装了grails和mysql,它似乎工作。 很抱歉打扰了你们所有人。 谢谢。

答案 1 :(得分:0)

问题是Mysql没有运行。首先运行apache和Mysql然后运行grails app.Hope它会工作。还检查80端口是否空闲,如果没有,那么释放你的80端口。

答案 2 :(得分:0)

同样的问题..突然.. MySQLWorkbench运行良好,但grails“无法创建池的初始连接”

我花了半天的时间试图解决这个问题,寻找答案。但没有什么对我有用..