views:

523

answers:

2

I've got a grails 1.1 web app running great in development but when I try and run it in production with an sqlserver database it crashes in a weird way.

The relevant part of my datasource.groovy is as follows:

environments {
    development {
     dataSource {
      dbCreate = "create-drop" // one of 'create', 'create-drop','update'
      url = "jdbc:hsqldb:mem:devDB"
     }
    }
    test {
     dataSource {
      dbCreate = "update"
      url = "jdbc:hsqldb:mem:testDb"
     }
    }
    production {

     dataSource {
      dbCreate = "update"
      driverClassName = "com.microsoft.sqlserver.jdbc.SQLServerDriver"
      endUsername = "sa"
      password = "pw4db"
      url = "jdbc:sqlserver://localhost:1433;databaseName=ReleasePlanner;selectMethod=cursor"

The error message I receive is:

Message: No such property: save for class: JsecRole
Caused by: groovy.lang.MissingPropertyException: No such property: save for class: JsecRole
Class: ProjectController
At Line: [28]
Code Snippet:
27: println "###about to create project roles"
28: userManagerService.createProjectRoles(project)
29: userManagerService.addUserToProject(session.user.id.toString(), project, 'owner')       
     }
    }
}

The stacktrace is as follows:

org.codehaus.groovy.runtime.InvokerInvocationException: groovy.lang.MissingPropertyException: No such property: save for class: JsecRole

    at org.jsecurity.web.servlet.JSecurityFilter.doFilterInternal(JSecurityFilter.java:382)

    at org.jsecurity.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:180)

Caused by: groovy.lang.MissingPropertyException: No such property: save for class: JsecRole

    at UserManagerService.createProjectRoles(UserManagerService.groovy:9)

    at UserManagerService$$FastClassByCGLIB$$6fa73713.invoke(<generated>)

    at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)

    at UserManagerService$$EnhancerByCGLIB$$fcf60984.createProjectRoles(<generated>)

    at UserManagerService$createProjectRoles.call(Unknown Source)

    at ProjectController$_closure4.doCall(ProjectController.groovy:28)

    at ProjectController$_closure4.doCall(ProjectController.groovy)

    ... 2 more

Any help is appreciated.

Thanks Sarah

A: 

I fixed my problem by deleting my database and creating a new database. I think some of the fields in my database weren't mapping correctly as I changed my domain objects. The error didn't really point me in this direction though!

Sarah

Sarah Boyd
A: 

This problem is discussed in this thread on the Grails mailing list. It is supposed to be fixed in Grails 1.2. A workaround for earlier versions of Grails is to add the following to Bootstrap.groovy

JsecRole.get(-1)
Don