使用Grails 2.4.3的MongoDB(3.0.2)NullPointerException

时间:2015-04-21 17:45:48

标签: mongodb grails amazon-ec2

我正在尝试在EC2上设置Grails Web应用程序

InstanceType:m3 xlarge

http://www.webupd8.org/2012/01/install-oracle-java-jdk-7-in-ubuntu-via.html

安装了JAVA

版本:     java版“1.7.0_80”     Java(TM)SE运行时环境(版本1.7.0_80-b15)     Java HotSpot(TM)64位服务器VM(内置24.80-b11,混合模式)

(因为JAVA 8遇到问题:https://github.com/spring-projects/spring-loaded/issues/98

从GVMtools安装Grails

http://gvmtool.net/

grails version : 2.4.3

安装mongoDB

http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/

版本     MongoDB shell版本:3.0.2     连接到:测试

我的DataSource.groovy配置是:

environments {
    development {
        grails {
            mongo {
                host = "localhost"
                port = 27017
                username = "root"
                password = "root"
                databaseName = "someDatabase"
            }
        }
        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"
        } 
    }

我的Buildconfig.groovy有最新的mongo插件:

compile ":mongodb:3.0.3"

但启动服务器后

grails run-app

并打开我收到此页面的任何页面

Error:

Stacktrace follows:
Message: null
    Line | Method
->>  833 | executeQuery     in      org.grails.datastore.mapping.mongo.query.MongoQuery
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    542 | list             in org.grails.datastore.mapping.query.Query
|     49 | invokeQuery . .  in org.grails.datastore.gorm.finders.FindAllByFinder
|     43 | doInSession      in org.grails.datastore.gorm.finders.FindAllByFinder$1
|    302 | execute . . . .  in org.grails.datastore.mapping.core.DatastoreUtils
|     41 | execute          in org.grails.datastore.gorm.finders.AbstractFinder
|     40 | doInvokeInternal in org.grails.datastore.gorm.finders.FindAllByFinder
|    152 | invoke           in org.grails.datastore.gorm.finders.DynamicFinder
|    352 | invoke . . . . . in     ''
|    105 | methodMissing    in org.grails.datastore.gorm.GormStaticApi
|     32 | call . . . . . . in org.grails.datastore.gorm.internal.StaticMethodInvokingClosure
|     49 | function    in someDomain
|     25 | listAllResources in in.org.api.APIController
|     16 | index            in     ''
|    198 | doFilter . . . . in grails.plugin.cache.web.filter.PageFragmentCachingFilter
|     63 | doFilter         in grails.plugin.cache.web.filter.AbstractFilter
|     53 | doFilter . . . . in   grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilte r
|     49 | doFilter         in grails.plugin.springsecurity.web.authentication.RequestHolderAuthenticationFilter
|     82 | doFilter . . . . in grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter
|   1145 | runWorker        in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . . . .  in java.util.concurrent.ThreadPoolExecutor$Worker
     745 | run              in java.lang.Thread

PS:我也尝试过创建用户并对其进行身份验证(Grails - Connect to a MongoDB database using authentication

使用db.createUser。

配置有什么问题,完全相同的配置在我的本地计算机上运行正常。

1 个答案:

答案 0 :(得分:1)

我创建了一个具有相同版本的实例,它工作正常。您是否尝试过使用grails,然后运行该应用程序。