当我们使用Bean验证时,它运行正常。但运行一段时间后,就会出现RuntimeException:
javax.validation.ValidationException: Unable to get available provider resolvers.
at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:265)
at javax.validation.Validation.buildDefaultValidatorFactory(Validation.java:110)
at org.dacell.app.order.isale.service.IsaleTradeValidate.validate(IsaleTradeValidate.java:40)
at org.dacell.app.order.isale.service.IsaleTradeValidate$$FastClassByCGLIB$$15097933.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:698)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:80)
at org.dacell.aspect.ValidateLogAspect.around(ValidateLogAspect.java:49)
at sun.reflect.GeneratedMethodAccessor1869.invoke(Unknown Source)
lib :hibernate-validator-5.0.1.Final.jar
答案 0 :(得分:2)
我从WebSphere得到了这个错误。 validation-api-1.0.0.GA.jar一直被添加到目标EAR文件中。在我将类加载策略更改为“parent last”之前,这从来都不是问题。我也得到了这个例外:
java.lang.ClassCastException:org.apache.bval.jsr303.ApacheValidationProvider与javax.validation.spi.ValidationProvider不兼容
解决方案是通过添加以下依赖项从目标EAR文件中删除validation-api-1.0.0.GA.jar,该依赖项将validation-api设置为“provided”:
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
<scope>provided</scope>
</dependency>