0
votes

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.

1
I have been part of similar problems, is User imported? Is the springSecurityService injected properly? - marko
As an experiment, what happens if you assign user.id to a variable, print out the variable (just to make sure it exists), and then do the User.get(variableName) - Though depending on the User object- you might consider User.findByUserId(variableName) - BZ.

1 Answers

0
votes

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.