0

Im toying with grails but i'm having troubles when render JSON in the controller, i have this code

import grails.converters.*

        class CourseController {
        def index = { redirect(action:list,params:params) }
        // the delete, save and update actions only accept POST requests
            static allowedMethods = [delete:'POST', save:'POST', update:'POST']

            def list = {
                params.max = Math.min( params.max ? params.max.toInteger() : 10,  100)
                //[ courseInstanceList: Course.list( params ) , courseInstanceTotal: Course.count() ]
                def courses = Course.list( params )
                // return a bunch of json data with metadata.
                def json = [        
                     totalCount: courses.size,
                     results: courses
                ]

                render json as JSON


            }
    //other methods.... that i didn't touch
}

But when i execute the "run-app" command i get the fallowing error:

unable to resolve class org.codehaus.groovy.grails.co
mmons.metaclass.ExpandoMetaClass
 @ line 4, column 1.
   import org.codehaus.groovy.grails.commons.metaclass.ExpandoMetaClass

i really don't know why :(

1
  • could you post the whole source file? the code you've posted already looks quite valid. maybe there's an invalid import at the top of your file? Commented Oct 12, 2009 at 12:06

1 Answer 1

2

That looks like a Grails install error - is GRAILS_HOME set properly?

Or a clash of Groovy jars - are there two versions of Groovy on the classpath somehow?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.