Я пытаюсь добавить пользовательское сообщение на мой валидатор, как это:Grails пользовательских сообщений проверки, ошибка
static constraints = {
joining validator: { val, obj ->
if(val?.after(obj.birthday)) return 'joining.error'
}
}
Конечно, я настроил файл messages.properties. Я получаю следующее исключение:
2015-04-30 16:52:27,253 [localhost-startStop-1] ERROR context.GrailsContextLoaderListener - Error initializing the application: No signature of method: usermanagement.UserRole.exists() is applicable for argument types: (null, java.lang.Long) values: [null, 1]
Possible solutions: exists(long, long), exists(java.io.Serializable), list(), first(), wait(), last()
Message: No signature of method: usermanagement.UserRole.exists() is applicable for argument types: (null, java.lang.Long) values: [null, 1]
Possible solutions: exists(long, long), exists(java.io.Serializable), list(), first(), wait(), last()
Line | Method
->> 92 | methodMissing in org.grails.datastore.gorm.GormStaticApi
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 86 | doCall in usermanagement.UserRole$__clinit__closure9$_closure14$_closure15
| 85 | doCall . . . . . . . . . . . . . in usermanagement.UserRole$__clinit__closure9$_closure14
| 44 | create in usermanagement.UserRole
| 19 | doCall . . . . . . . . . . . . . in BootStrap$_closure1
| 327 | evaluateEnvironmentSpecificBlock in grails.util.Environment
| 320 | executeForEnvironment . . . . . in ''
| 296 | executeForCurrentEnvironment in ''
| 266 | run . . . . . . . . . . . . . . in java.util.concurrent.FutureTask
| 1142 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 617 | run . . . . . . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run in java.lang.Thread
Я действительно не понимаю, почему существует связь с usermanagement.UserRole.exists()?
EDIT: UserRole генерируется основной SpringSecurity Plugin EDIT: Bootstrap.groovy:
import java.text.SimpleDateFormat
import usermanagement.*
class BootStrap {
def init = { servletContext ->
def adminRole = new Role(authority: 'ROLE_ADMIN').save(flush: true)
def userRole = new Role(authority: 'ROLE_USER').save(flush: true)
def birthday_sdf = new SimpleDateFormat("dd-M-yyyy hh:mm:ss")
def birthday_str = "31-08-1982 10:20:56"
def testUser = new User(username: 'me', password: 'password',
firstName: 'Adam', lastName: 'Administrator',
role: adminRole, email: '[email protected]',
birthday: birthday_sdf.parse(birthday_str), joining: new Date())
testUser.save(flush: true)
UserRole.create testUser, adminRole, true
}
}
ваша ошибка относится к содержимому вашей строки Bootstrap.groovy 19 | doCall. , , , , , , , , , , , , в BootStrap $ _closure1 – Vahid
нормально, я только что отредактировал bootstrap.groovy в своем первом сообщении. Я действительно не знаю, что мне нужно изменить здесь, так как приложение просто отлично работает без оператора return в ограничении – user3667018