编辑:问题解决了,我在配置中输错了“生产”。愚蠢的错误......
我使用MongoDB创建了一个小型骨架Grails应用程序,该应用程序在我的本地计算机上运行。我可以使用bees app:deploy target/proj-0.1.war -appid user/proj
在CloudBees上成功部署应用程序,它可以正常工作(当然除了DB)。
然后我使用MongoHQ创建了一个MongoDB并收到了地址mongodb://cloudbees:123@paulo.mongohq.com:10044/456
。基于此,我编辑了我的“DataSource.groovy”如下:
environments {
development {
grails {
mongo {
host = 'localhost'
port = 27017
databaseName = 'db'
}
}
}
test {
grails {
mongo {
host = 'localhost'
port = 27017
databaseName = 'db'
}
}
}
producution {
grails {
mongo {
// based on: cloudbees:123@paulo.mongohq.com:10044/456
host = 'paulo.mongohq.com'
port = 10044
username = 'cloudbees'
password = '123'
databaseName = '456'
}
}
}
}
但是,当我使用以下命令部署应用程序时
bees config:set -a proj -P grails.env=production
grails war
bees app:deploy target/proj-0.1.war -appid user/proj
bees app:tail user/proj
然后在浏览器中打开URL,一旦向DB发出第一个请求,我就会收到以下错误:
Sep 11, 2013 8:24:49 AM com.mongodb.DBTCPConnector initDirectConnection
WARNING: Exception executing isMaster command on /127.0.0.1:27017
java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at com.mongodb.DBPort._open(DBPort.java:223)
at com.mongodb.DBPort.go(DBPort.java:125)
at com.mongodb.DBPort.go(DBPort.java:106)
at com.mongodb.DBPort.findOne(DBPort.java:162)
at com.mongodb.DBPort.runCommand(DBPort.java:170)
at com.mongodb.DBTCPConnector.initDirectConnection(DBTCPConnector.java:533)
at com.mongodb.DBTCPConnector.isMongosConnection(DBTCPConnector.java:334)
at com.mongodb.Mongo.isMongosConnection(Mongo.java:618)
at com.mongodb.DB.wrapCommand(DB.java:281)
at com.mongodb.DB.command(DB.java:259)
at com.mongodb.DB.command(DB.java:243)
at com.mongodb.DBCollection.getCount(DBCollection.java:985)
at com.mongodb.DBCursor.size(DBCursor.java:602)
[...]
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)
Sep 11, 2013 8:24:49 AM com.mongodb.DBTCPConnector initDirectConnection
WARNING: Exception executing isMaster command on /127.0.0.1:27017
java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at com.mongodb.DBPort._open(DBPort.java:223)
[...]
at java.lang.Thread.run(Unknown Source)
Sep 11, 2013 8:24:49 AM com.mongodb.DBPortPool gotError
WARNING: emptying DBPortPool to /127.0.0.1:27017 b/c of error
java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at com.mongodb.DBPort._open(DBPort.java:223)
at com.mongodb.DBPort.go(DBPort.java:125)
at com.mongodb.DBPort.call(DBPort.java:92)
at com.mongodb.DBTCPConnector.innerCall(DBTCPConnector.java:244)
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:216)
at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:288)
at com.mongodb.DB.command(DB.java:261)
at com.mongodb.DB.command(DB.java:243)
at com.mongodb.DBCollection.getCount(DBCollection.java:985)
at com.mongodb.DBCursor.size(DBCursor.java:602)
[...]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)
2013-09-11 08:24:49,677 [http-8422-1] ERROR errors.GrailsExceptionResolver - ConnectException occurred when processing request: [GET] /project/list
Connection refused. Stacktrace follows:
java.net.ConnectException: Connection refused
at com.mongodb.DBPort._open(DBPort.java:223)
at com.mongodb.DBPort.go(DBPort.java:125)
at com.mongodb.DBPort.call(DBPort.java:92)
at com.mongodb.DBTCPConnector.innerCall(DBTCPConnector.java:244)
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:216)
at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:288)
at com.mongodb.DB.command(DB.java:261)
at com.mongodb.DB.command(DB.java:243)
at com.mongodb.DBCollection.getCount(DBCollection.java:985)
[...]
at net.stax.appserver.webapp.RequestSetupValve.invoke(RequestSetupValve.java:31)
在http://wiki.cloudbees.com/bin/view/RUN/MongoHQ上,它表示我也可以按如下方式使用绑定:
bees app:bind -a proj -r mongohq:db -as DB
但是,我不确定这对这个问题有什么帮助。有任何想法吗?我在“DataSource.groovy”中的条目是错误的吗?谢谢你的帮助。
答案 0 :(得分:1)
您在配置“生产”与“生产”中输入了拼写错误
对于绑定资源,您可以使用:
def url = System.getProperty('MONGOHQ_URL_DB')
在grails配置文件中,但CloudBees只注入完整的URL,而不是主机,端口等,因此可以使用新的java.net.URI(url).host