问题
My grails app can connect to my local mongodb and works fine but when I deploy to cloud foundry, I get a connection refused error trying to connect to mongodb on cf.
I bound a mongodb service to my app, but it still can't connect?
barry-alexanders-MacBook-Pro:~ barryalexander$ vmc apps
+-------------+----+---------+-------------------------+-----------------+
| Application | # | Health | URLS | Services |
+-------------+----+---------+-------------------------+-----------------+
| RelCal | 1 | RUNNING | relcal.cloudfoundry.com | mongodb-a77900c |
| barry | 1 | STOPPED | barry.cloudfoundry.com | |
+-------------+----+---------+-------------------------+-----------------+
Here's the stack trace after hitting my app at http://relcal.cloudfoundry.com/release/calendar
Line | Method
->> 228 | _open in com.mongodb.DBPort
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 112 | go in ''
| 79 | call . . in ''
| 218 | call in com.mongodb.DBTCPConnector
| 305 | __find . in com.mongodb.DBApiLayer$MyCollection
| 369 | _check in com.mongodb.DBCursor
| 498 | _hasNext in ''
| 523 | hasNext in ''
| 40 | hasNext in com.google.code.morphia.query.MorphiaIterator
| 258 | asList in com.google.code.morphia.query.QueryImpl
| 20 | doCall . in com.gap.release.calendar.RelCalRestController$_closure1
^ 662 | run in java.lang.Thread
I'm missing something but don't know what.
回答1:
At this time, when deploying grails/mongo apps to cloudfoundry, it's best to use the approach described at Cloud Foundry Services - Using MongoDB with Grails rather than using morphia.
来源:https://stackoverflow.com/questions/12152411/grails-mongodb-connection-refused