我有一个部署到Weblogic 12c容器的spring boot web应用程序。
我有弹簧MVC映射processEvent(@Valid @RequestBody UpstreamEvent event)
我的weblogic.xml
文件包含:
<container-descriptor>
<prefer-web-inf-classes>false</prefer-web-inf-classes>
<prefer-application-packages>
<package-name>com.google.*</package-name>
<package-name>javax.persistence.*</package-name>
<package-name>javax.persistence.spi*</package-name>
<package-name>org.apache.commons.*</package-name>
<package-name>org.hibernate.*</package-name>
<package-name>javax.validation.*</package-name>
<package-name>org.jboss.logging.*</package-name>
<package-name>com.fasterxml.classmate.*</package-name>
<package-name>org.joda.*</package-name>
<package-name>org.springframework.*</package-name>
<package-name>org.slf4j.*</package-name>
<package-name>ch.qos.logback.*</package-name>
<package-name>org.objectweb.asm.*</package-name>
<package-name>antlr.*</package-name>
<package-name>javassist.*</package-name>
</prefer-application-packages>
</container-descriptor>
当请求进入时,输入得到验证,我得到例外情况如下:
17-10-23 18:39:03.930 [[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'] ERROR o.springframework.boot.web.support.ErrorPageFilter [] - Forwarding to error page from request [/api/playground/process-event] due to exception [HV000041: Call to TraversableResolver.isReachable() threw an exception.]
javax.validation.ValidationException: HV000041: Call to TraversableResolver.isReachable() threw an exception.
at org.hibernate.validator.internal.engine.ValidatorImpl.isReachable(ValidatorImpl.java:1652)
at org.hibernate.validator.internal.engine.ValidatorImpl.isValidationRequired(ValidatorImpl.java:1628)
at org.hibernate.validator.internal.engine.ValidatorImpl.validateMetaConstraint(ValidatorImpl.java:612)
at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraint(ValidatorImpl.java:583)
at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForSingleDefaultGroupElement(ValidatorImpl.java:527)
at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForDefaultGroup(ValidatorImpl.java:495)
at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForCurrentGroup(ValidatorImpl.java:460)
at org.hibernate.validator.internal.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:410)
at org.hibernate.validator.internal.engine.ValidatorImpl.validate(ValidatorImpl.java:207)
at org.springframework.validation.beanvalidation.SpringValidatorAdapter.validate(SpringValidatorAdapter.java:118)
at org.springframework.boot.autoconfigure.web.WebMvcValidator.validate(WebMvcValidator.java:69)
at org.springframework.validation.DataBinder.validate(DataBinder.java:891)
at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver.validateIfApplicable(AbstractMessageConverterMethodArgumentResolver.java:270)
at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.resolveArgument(RequestResponseBodyMethodProcessor.java:133)
at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:121)
at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:158)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:128)
Caused by: java.lang.ClassCastException: org.eclipse.persistence.jpa.PersistenceProvider cannot be cast to javax.persistence.spi.PersistenceProvider
at javax.persistence.Persistence$1.isLoaded(Persistence.java:110)
at org.hibernate.validator.internal.engine.resolver.JPATraversableResolver.isReachable(JPATraversableResolver.java:47)
at org.hibernate.validator.internal.engine.resolver.DefaultTraversableResolver.isReachable(DefaultTraversableResolver.java:128)
at org.hibernate.validator.internal.engine.resolver.CachingTraversableResolverForSingleValidation.isReachable(CachingTraversableResolverForSingleValidation.java:36)
at org.hibernate.validator.internal.engine.ValidatorImpl.isReachable(ValidatorImpl.java:1643)
... 104 common frames omitted
它似乎是一些类路径问题,即使我更喜欢hibernate验证器及其依赖项。
当我的应用程序部署到Tomcat时,我没有看到这些异常。
为什么我得到例外?
答案 0 :(得分:1)
对我来说,我可以通过在weblogic.xml中添加以下内容来使其工作
<wls:prefer-application-resources>
<wls:resource-name>META-INF/services/javax.persistence.spi.PersistenceProvider</wls:resource-name>
</wls:prefer-application-resources>