【问题标题】:Cloud Foundry v2 in GrailsGrails 中的 Cloud Foundry v2
【发布时间】:2014-10-02 04:00:13
【问题描述】:

我有一个 grails 项目,我想将它部署在 Cloud Foundry 上,但控制台显示如下:

[CONTAINER] n.spring.CloudProfileApplicationContextInitializer INFO    Adding 'cloud' to list of active profiles
[CONTAINER] g.CloudPropertySourceApplicationContextInitializer INFO    Adding 'cloud' PropertySource to ApplicationContext
[CONTAINER] udAutoReconfigurationApplicationContextInitializer INFO    Adding cloud service auto-reconfiguration to ApplicationContext
[CONTAINER] ing.DataSourceCloudServiceBeanFactoryPostProcessor INFO    Auto-reconfiguring beans of type javax.sql.DataSource
[CONTAINER] ing.DataSourceCloudServiceBeanFactoryPostProcessor INFO    No beans of type javax.sql.DataSource found. Skipping auto-reconfiguration.
[CONTAINER] lina.core.ContainerBase.[Catalina].[localhost].[/] SEVERE  Exception sending context initialized event to listener instance of class org.codehaus.groovy.grails.web.context.GrailsContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pluginManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NullPointerException: Cannot invoke method getAt() on null object
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
Caused by: java.lang.NullPointerException: Cannot invoke method getAt() on null object
    at java.lang.Thread.run(Thread.java:745)
[CONTAINER] org.apache.catalina.core.StandardContext           SEVERE  Error listenerStart
    ... 5 more
[CONTAINER] org.apache.catalina.util.SessionIdGeneratorBase    INFO    Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [135] milliseconds.
[CONTAINER] org.apache.catalina.core.StandardContext           SEVERE  Context [] startup failed due to previous errors
[CONTAINER] org.apache.catalina.loader.WebappClassLoader       WARNING The web application [] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
[CONTAINER] org.apache.catalina.loader.WebappClassLoader       WARNING The web application [] registered the JDBC driver [org.h2.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
 java.lang.Object.wait(Native Method)
[CONTAINER] org.apache.catalina.loader.WebappClassLoader       WARNING The web application [] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:142)

我认为这是 DB Conex 的问题,但我不知道如何解决。我在我的应用程序和服务计划 ClearDB MySQL Database Spark DB 中使用 MySQL。

我的Datasource.groovy 是:

import org.springframework.cloud.CloudFactory

def cloud

try {
  cloud = new CloudFactory().cloud
} catch(e) {}

dataSource {
    pooled = true
    driverClassName = "com.mysql.jdbc.Driver"
    dialect = "org.hibernate.dialect.MySQL5InnoDBDialect"
    username = "root"
    password = "root"
}
hibernate {
    cache.use_second_level_cache = true
    cache.use_query_cache = true
    cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
    //cache.region.factory_class = 'org.hibernate.cache.EhCacheProvider'
}
environments {
    development {
        dataSource {
            dbCreate = "create-drop"
            url = "jdbc:mysql://localhost:8080/bbddSRL"
            username="root"
            password="root"
        }
    }
    test {
        dataSource {
            dbCreate = "create-drop"
            url = "jdbc:mysql://localhost:8080/bbddSRL"
            username="root"
            password="root"
        }
    }
production {
        dataSource {
          pooled = true
          dbCreate = 'update'
          driverClassName = 'com.mysql.jdbc.Driver'

          if (cloud) {
            def dbInfo = cloud.getServiceInfo('mysql-instance') //mysql-instance is the name of the ClearDB's service.
            url = dbInfo.jdbcUrl
            username = dbInfo.userName
            password = dbInfo.password
          } else {
            url = 'jdbc:mysql://localhost:8080/bbddSRLprod'
            username = 'root'
            password = 'root'
          }
        }
    }
}

有什么意见或建议吗?

【问题讨论】:

    标签: mysql grails groovy cloud cloud-foundry


    【解决方案1】:

    尝试消除定义方言的数据源块。您仍然必须在该块中定义项目,但在每个环境的数据源中进行。我这样做是因为我对环境中的数据源所做的任何更改似乎都没有效果。

    【讨论】:

    • 我删除了数据源块,但问题仍然存在。 :(
    • 没人知道吗? =(
    猜你喜欢
    • 1970-01-01
    • 2016-03-20
    • 1970-01-01
    • 2017-02-28
    • 1970-01-01
    • 1970-01-01
    • 2013-11-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多