Search code examples
grailsgroovygrails-orm

Grails GORM MissingMethodException


new to groovy and stuck on this for quite some time.

Heres the method in question.

protected User currentUser() {
        def user = springSecurityService.currentUser
        println "In currentUser Method"
        println "Is userId null?"
        println user.id == null
        println user.id instanceof Long

User.get(user.id)
}

And User.get is a method in the GORM package

D get(Serializable id) {
        execute({ Session session ->
           session.retrieve(persistentClass, id)
        } as SessionCallback)
    }

Im getting the error

No signature of method: User.get() is applicable for argument types: () values: []

What I dont understand is that through the println statements I verified that

  1. user.id is not null
  2. user.id is instanceof Long , which implements the Serializable interface.

Any idea whats happening here?

Thank you.


Solution

  • A possible solution could be that you have an invalid import statement. User is a very common class name so maybe you (or your IDE) have imported a different User class than you expect. The imported class might not have a get(id) method.