Pergunta

after upgrading from grails 1.3.7 to 2.0.1 i'm getting follwong strange exception when validating command object within a controller.

  groovy.lang.GroovyRuntimeException: Ambiguous method overloading for method org.codehaus.groovy.grails.orm.hibernate.HibernateGormValidationApi#validate.
Cannot resolve which method to invoke for [class at.pdts.etsweb.commandobject.UserCommand, null] due to overlapping prototypes between:
    [class java.lang.Object, interface java.util.List]
    [class java.lang.Object, interface java.util.Map]

    at org.grails.datastore.gorm.InstanceMethodInvokingClosure.call(GormEnhancer.groovy:251)

    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

    at java.lang.Thread.run(Thread.java:662)

My UserCommand command object looks like this:

package at.pdts.etsweb.commandobject

import at.pdts.etsweb.Common
import grails.validation.Validateable

    @Validateable
    class UserCommand { 
        String username
        String password
        String firstname
        String lastname 
        static constraints = {
            username blank: false, email: true
            password blank: false, minSize: 8, maxSize: 64, validator: Common.passwordValidator
            firstname blank: false
            lastname blank: false
        }
    }

The controller binds the data as follows:

def save { UserCommand command ->

...
}

At this point i'm getting the above error message. i tried also to use the command object as an argument save(UserCommand command), but with no effect. Does anyone have some hint?

Foi útil?

Solução

My workaround was to move the command object classes from the /grails-app/controller to /src/groovy. After that the error disappeared.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top