I’m following the instructions on this link which recommend I update my bootstrap groovy class.
// Bootstrap.groovy
import grails.converters.JSON
class BootStrap {
def init = { servletContext ->
JSON.registerObjectMarshaller(UserMapping) {
def rA = [:]
ra['userId'] = it.id
}
}
def destroy = {
}
}
But it returns the error:
ERROR context.GrailsContextLoader - Error initializing the application: No such property: UserMapping for class: BootStrap
Message: No such property: UserMapping for class: BootStrap
My domain class looks like:
# UserMapping.groovy
package engagementlevels
class UserMapping {
String username
String email
Date insertTime
String type
String flags
static belongsTo = [groupMapping: GroupMapping]
static mapping = {
// Custom Mappings here
}
static hibernateFilters = {
// Filters here
}
transient beforeInsert = {
throw new RuntimeException('create not allowed')
}
transient beforeUpdate = {
throw new RuntimeException('update not allowed')
}
transient beforeDelete = {
throw new RuntimeException('delete not allowed')
}
}
It’s in the “engagementlevels” package but BootStrap.groovy is in the default package. Add an import for the class: