Search code examples
validationjbosswildflybean-validationwildfly-8

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


I'm using JSR 303 Bean validation on my RestEasy endpoints:

@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();
    }
}

when I startup Wildfly 8.2.0.Final I get the following exception:

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$1.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]

At first I though it depends on the first WARN and found this entry: https://issues.jboss.org/browse/WFLY-3812 I checked the solution but in /opt/wildfly/modules/system/layers/base/org/picketlink/core/main/module.xml there are these dependencies:

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

Maybe it has no effect or it does not even affect the validation WARN:

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

I didn't add any own implementations of any Validator. Do I miss anything here to get bean validation to work?


Solution

  • It really smells like a classloading issue. You should make sure you do not package any of the provided EE dependencies in your war/ear archive (resteasy-hibernatevalidator, hibernate-, weld-).