类型接口 org.hibernate.validator.method.MethodValidator 不支持展开

Type interface org.hibernate.validator.method.MethodValidator not supported for unwrapping

我在我的 RestEasy 端点上使用 JSR 303 Bean 验证:

@Path("/")
@Produces(MediaType.APPLICATION_JSON)
@ValidateRequest
public class RecipeEndpoint
{
    //more code

    @GET
    @Path("/get/{accessId}")
    @Consumes(MediaType.TEXT_PLAIN)
    public Response getByAccessId(@PathParam("accessId") @NotEmpty String accessId) throws InternalServerErrorException
    {
        RecipeBo result = recipeService.getByAccessId(accessId, userId);

        return Response.ok().entity(result).build();
    }
}

当我启动 Wildfly 8.2 时。0.Final 我得到以下异常:

18:14:36,035 WARN  [org.jboss.as.weld] (MSC service thread 1-1) JBAS016018: Using deployment classloader to load proxy classes for module org.jboss.resteasy.resteasy-validator-provider-11:main. Package-private access will not work. To fix this the module should declare dependencies on [org.jboss.weld.core, org.jboss.weld.spi]
18:14:36,232 INFO  [org.jboss.resteasy.spi.ResteasyDeployment] (MSC service thread 1-1) Deploying javax.ws.rs.core.Application: class com.mysite.myapp.domain.JaxRsActivator
18:14:36,291 WARN  [org.jboss.resteasy.plugins.validation.hibernate.AbstractValidatorContextResolver] (MSC service thread 1-1) Unable to load Validation support: javax.validation.ValidationException: HV000036: Type interface org.hibernate.validator.method.MethodValidator not supported for unwrapping.
    at org.hibernate.validator.internal.engine.ValidatorImpl.unwrap(ValidatorImpl.java:336) [hibernate-validator-5.1.3.Final.jar:5.1.3.Final]
    at org.jboss.resteasy.plugins.validation.hibernate.AbstractValidatorContextResolver.getGeneralValidator(AbstractValidatorContextResolver.java:47) [resteasy-hibernatevalidator-provider-3.0.11.Final.jar:]
    at org.jboss.resteasy.plugins.validation.hibernate.AbstractValidatorContextResolver.getContext(AbstractValidatorContextResolver.java:54) [resteasy-hibernatevalidator-provider-3.0.11.Final.jar:]
    at org.jboss.resteasy.plugins.validation.hibernate.ValidatorContextResolver.getContext(ValidatorContextResolver.java:16) [resteasy-hibernatevalidator-provider-3.0.11.Final.jar:]
    at org.jboss.resteasy.plugins.validation.hibernate.ValidatorContextResolver$Proxy$_$$_WeldClientProxy.getContext(Unknown Source) [resteasy-hibernatevalidator-provider-3.0.11.Final.jar:]
    at org.jboss.resteasy.spi.ResteasyProviderFactory.getContext(ResteasyProviderFactory.java:2190) [resteasy-jaxrs-3.0.10.Final.jar:]
    at org.jboss.resteasy.core.ResourceMethodInvoker.<init>(ResourceMethodInvoker.java:118) [resteasy-jaxrs-3.0.10.Final.jar:]
    at org.jboss.resteasy.core.ResourceMethodRegistry.processMethod(ResourceMethodRegistry.java:280) [resteasy-jaxrs-3.0.10.Final.jar:]
    at org.jboss.resteasy.core.ResourceMethodRegistry.register(ResourceMethodRegistry.java:251) [resteasy-jaxrs-3.0.10.Final.jar:]
    at org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:221) [resteasy-jaxrs-3.0.10.Final.jar:]
    at org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:193) [resteasy-jaxrs-3.0.10.Final.jar:]
    at org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:179) [resteasy-jaxrs-3.0.10.Final.jar:]
    at org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:156) [resteasy-jaxrs-3.0.10.Final.jar:]
    at org.jboss.resteasy.core.ResourceMethodRegistry.addPerRequestResource(ResourceMethodRegistry.java:75) [resteasy-jaxrs-3.0.10.Final.jar:]
    at org.jboss.resteasy.spi.ResteasyDeployment.registration(ResteasyDeployment.java:400) [resteasy-jaxrs-3.0.10.Final.jar:]
    at org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:241) [resteasy-jaxrs-3.0.10.Final.jar:]
    at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.init(ServletContainerDispatcher.java:112) [resteasy-jaxrs-3.0.10.Final.jar:]
    at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.init(HttpServletDispatcher.java:36) [resteasy-jaxrs-3.0.10.Final.jar:]
    at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:117) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
    at org.wildfly.extension.undertow.security.RunAsLifecycleInterceptor.init(RunAsLifecycleInterceptor.java:79)
    at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:103) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.servlet.core.ManagedServlet$DefaultInstanceStrategy.start(ManagedServlet.java:220) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.servlet.core.ManagedServlet.createServlet(ManagedServlet.java:125) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
    at io.undertow.servlet.core.DeploymentManagerImpl.start(DeploymentManagerImpl.java:508) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
    at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:88)
    at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.start(UndertowDeploymentService.java:72)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_80]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_80]
    at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_80]

起初我虽然它取决于第一个 WARN 并找到了这个条目: https://issues.jboss.org/browse/WFLY-3812 我检查了解决方案,但在 /opt/wildfly/modules/system/layers/base/org/picketlink/core/main/module.xml 中有这些依赖项:

<module name="org.jboss.weld.core"/>
<module name="org.jboss.weld.spi"/>

可能没有效果,甚至不影响验证警告:

Type interface org.hibernate.validator.method.MethodValidator not supported for unwrapping.

我没有添加任何验证器的任何自己的实现。我是否遗漏了任何让 bean 验证工作的东西?

@ValidateRequest 不是 JSR 303 的一部分,这是用作 Bean Validation 1.0 一部分的注释。

确保您只使用 bean validation 1.1 标签并且应该没问题。

这确实像是一个类加载问题。你应该确保你在你的war/ear存档中打包任何提供的EE依赖项(resteasy-hibernatevalidator,hibernate-,weld-).