Grails中的Cloud Foundry v2

时间:2014-10-01 14:44:19

标签: mysql grails groovy cloud cloudfoundry

我有一个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'
          }
        }
    }
}

任何修改或建议?

1 个答案:

答案 0 :(得分:0)

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