带有Hibernate的Grails 2.4.4找不到ValidatorFactory类

时间:2015-03-17 07:51:06

标签: grails

使用" ClassNotFoundException:javax.validation.ValidatorFactory"例外,我创建了具有最小功能的全新2.4.4应用程序。是的,我已经阅读过关于hibernate-validator-5.x.x and validation-api-1.0.x incompatibility2.4.4 Release Notes的内容,并根据建议添加了对validation-api:1.1.0和hibernate-validator:5.0.3到BuildConfig.groovy的依赖性,最后看起来如下:

grails.servlet.version = "3.0" 
grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
grails.project.work.dir = "target/work"
grails.project.target.level = 1.6
grails.project.source.level = 1.6

grails.project.fork = [
test: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, daemon:true],
run: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false],
war: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false],
console: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256]
]
grails.project.dependency.resolver = "maven" // or ivy
grails.project.dependency.resolution = {
inherits("global") {
}
log "error" 
checksums true 
legacyResolve false 

repositories {
    inherits true 
    grailsPlugins()
    grailsHome()
    mavenLocal()
    grailsCentral()
    mavenCentral()
}

dependencies {
    test "org.grails:grails-datastore-test-support:1.0.2-grails-2.4"
    compile 'javax.validation:validation-api:1.1.0.Final'
    runtime 'org.hibernate:hibernate-validator:5.0.3.Final'
}

plugins {
    build ":tomcat:7.0.55"
    compile ":scaffolding:2.1.2"
    compile ':cache:1.1.8'
    compile ":asset-pipeline:1.9.9"
    runtime ":hibernate4:4.3.6.1" 
    runtime ":database-migration:1.4.0"
    runtime ":jquery:1.11.1"
 }
}

之后,我添加了非常简单的基于hibernate的域类(跳过了brewity的代码),将其映射到hibernate.cfg.xml并执行了create-controller和run-app。瞧:" ClassNotFoundException:javax.validation.ValidatorFactory"。 我试图将hibernate-validator升级到5.1.3并将其降级到4.3.1(同时将validation-api降级到1.0.0)并将hibernate降级到4.3.5.5,但仍然没有运气。还有什么可以做的? 下面的完整错误转储:

 Error 2015-03-17 11:31:47,191 [localhost-startStop-1] ERROR context.GrailsContextLoaderListener  - Error initializing the application: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/validation/ValidatorFactory
Message: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/validation/ValidatorFactory
    Line | Method
->>  262 | run       in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    744 | run       in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/validation/ValidatorFactory
->>  262 | run       in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    744 | run       in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/validation/ValidatorFactory
->>  262 | run       in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    744 | run       in java.lang.Thread
Caused by NoClassDefFoundError: javax/validation/ValidatorFactory
->> 2531 | privateGetDeclaredMethods in java.lang.Class
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   2774 | getMethod0 in     ''
|   1663 | getMethod in     ''
|    262 | run       in java.util.concurrent.FutureTask
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    744 | run . . . in java.lang.Thread
Caused by ClassNotFoundException: javax.validation.ValidatorFactory
->>  366 | run       in java.net.URLClassLoader$1
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    355 | run       in     ''
|    354 | findClass in java.net.URLClassLoader
|    425 | loadClass in java.lang.ClassLoader
|    358 | loadClass in     ''
|   2531 | privateGetDeclaredMethods in java.lang.Class
|   2774 | getMethod0 in     ''
|   1663 | getMethod in     ''
|    262 | run . . . in java.util.concurrent.FutureTask
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    744 | run       in java.lang.Thread
| Error Forked Grails VM exited with error

更新:奇怪,但是' run-war'确实有效,没有错误,' run-app'没有。

0 个答案:

没有答案