2014-01-07 58 views
2

當我們使用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:冬眠 - 驗證 - 5.0.1.Final.jar

回答

0

我從WebSphere得到這個錯誤。 validation-api-1.0.0.GA.jar一直被添加到目標EAR文件中。直到我將類加載策略更改爲「最後一個父母」之前,這絕不是問題。我也得到此異常:

java.lang.ClassCastException:與javax.validation.spi.ValidationProvider

org.apache.bval.jsr303.ApacheValidationProvider不兼容的解決方案是去除驗證的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> 
相關問題