Results 1 to 3 of 3

Thread: Problem reading from MongoDB on CloudFoundry (Grails)

  1. #1
    Join Date
    Oct 2011
    Posts
    2

    Default Problem reading from MongoDB on CloudFoundry (Grails)

    Hi,

    I've got a Grails project successfully writing to and reading a MongoDB locally, but when I deploy it to CloudFoundry I get authentication issues, specifically:

    Code:
    com.mongodb.MongoException: unauthorized db:getyouthere lock type:-1 client:172.30.50.16
    It's a Grails project, with the mongodb 1.0M5 plugin installed. I'm using the low-level API since I don't need ORM (at present).

    Locally, everything is fine. I can write and read documents to MongoDB, with the following code (stripped down):

    Code A - Write

    Code:
    def mongo
    def getDocs() {
    def col = mongo.getDB("dbname")["colname"]
    def q = [sid: s.id.toInteger()]
    def o = [
    	sid: 1,
    	name: 'Hello world'
    ]
    col.update(q, o, true, false)
    }
    Code B - Read

    Code:
    def mongo
    def getDocs() {
    def col = mongo.getDB("dbname")["colname"]
    return col.findOne()
    }
    I have no changes to any config files.

    However, when I deploy this to CloudFoundry, I appear to be able to run Code A successfully, but not Code B. At least I get the above exception when I run code B, but not code A. Code A runs without exceptions, although I can't check that anything was actually written since I can run code B.

    I've tried installing the CloudFoundry plugin and seeing if the <cloud:mongo/> tag would work, but to be honest I got more errors that way and the app would start at all. I've also tried manually authenticating with the database using the environment variables, but that didn't change anything. I've also tried using the GORM features of the plugin but got errors that way too. I feel like Tantalus always nearly reaching my goal but never quite getting there

    It's a little frustrating because, owing to Grails's wonderfulness, I wrote my app in about 4 hours and have spent 4 days trying to deploy it to CLoudFoundry. I appreciate CF is still in early stages, but I get the feeling other people are having more luck than me.

    Anyone have any ideas? I can supply more info if it helps.

    Many thanks

    Digby

  2. #2
    Join Date
    Oct 2011
    Location
    San Francisco
    Posts
    2

    Default

    A few things to look for:
    1. did you uninstall the hibernate plugin, or are you using both?
    2. did you grails cf-push prod (maybe you pushed dev)?
    3. if none of the above solve it, can you publish the code for the smallest possible sample app that demonstrates the issue somewhere?
    --
    Patrick Chanezon
    Senior Director, Developer Relations, VMware
    http://cloudfoundry.com/
    http://wordpress.chanezon.com/

  3. #3
    Join Date
    Oct 2011
    Posts
    2

    Default

    Thanks for your reply. I am using both Hibernate and MongoDB plugins because I got another error when I tried removing Hibernate.

    I actually restarted the project from scratch and this time I used cf-push instead of drag-and-drop in STS with the CloudFoundry plugin, and that all worked - excellent! I'll try cf-push on the original and see if it makes a difference. I think I had everything set up propely - maybe the STS plugin isn't quite ready yet?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •