【问题标题】:Database may be already in use: “Locked by another process” when starting two grails apps from tomcat数据库可能已在使用中:从 tomcat 启动两个 grails 应用程序时“被另一个进程锁定”
【发布时间】:2015-02-22 22:26:13
【问题描述】:

我在 Tomcat 中部署了两个 grails 应用程序。启动应用程序时,我看到以下错误。我的应用程序无法启动。

org.h2.jdbc.JdbcSQLException:数据库可能已在使用中:“被另一个进程锁定”。可能的解决方案:关闭所有其他连接;使用服务器模式[90020-176]

这里是 DataSource.Groovy。

dataSource {
    pooled = true
    jmxExport = 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
    singleSession = true // configure OSIV singleSession mode
    flush.mode = 'manual' // OSIV session flush mode outside of transactional context
}

// environment specific settings
environments {
    development {
        dataSource {
            dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
            url = "jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
        }
    }
    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 {
               // 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
            }
        }
    }
}

如果我改变了

dbCreate = "update"

dbCreate = "create-drop" 

处于生产模式。

我可以启动两个应用中的任何一个,但不能同时启动。

两个嵌入式 H2 数据库似乎相互冲突?

【问题讨论】:

    标签: tomcat grails web-deployment h2


    【解决方案1】:

    更改生产 URL 中的文件名。从 ProdDB 到 ProdDB2 或类似的。

    但实际上,请使用适当的数据库。

    【讨论】:

    • 是的。工作。谢谢!
    猜你喜欢
    • 1970-01-01
    • 2011-12-30
    • 2015-07-07
    • 2015-11-20
    • 1970-01-01
    • 1970-01-01
    • 2012-10-31
    • 1970-01-01
    • 2017-01-30
    相关资源
    最近更新 更多