Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature to disable JSR-303 validation? #316

Open
cobbzilla opened this issue Jan 21, 2017 · 6 comments
Open

feature to disable JSR-303 validation? #316

cobbzilla opened this issue Jan 21, 2017 · 6 comments

Comments

@cobbzilla
Copy link

cobbzilla commented Jan 21, 2017

I would like to use jcabi for annotations like @RetryOnFailure, @Async and @Cacheable, but whenever I run my tests I get the following error:

java.lang.NoSuchMethodError: javax.validation.Validator.forExecutables()Ljavax/validation/executable/ExecutableValidator;

The project I'm working on has an existing Jersey/JAX-RS project that already has validation configured (@Valid tags on method parameters are handled by the framework), using a customized/subclassed version of the Hibernate validator.

Is there any way to disable JSR-303 validation via jcabi, if it is already being provided by someone else?

@0crat
Copy link

0crat commented Jan 21, 2017

@yegor256 please, pay attention to this issue

1 similar comment
@0crat
Copy link

0crat commented Jan 21, 2017

@yegor256 please, pay attention to this issue

@yegor256
Copy link
Member

@cobbzilla good question... Can you provide full stack trace please?

@cobbzilla
Copy link
Author

cobbzilla commented Feb 2, 2017

I've pasted a stack trace below. The signature for mypackage.AuthResource.login includes a parameter that is annotated with @Valid. My Jersey/JAX-RS container is already handling validation for this. It seems that when the jcabi aspects were woven-in at compile time, it added some code here that is messing up validation. Would it be possible to disable certain annotations in the maven plugin that handles the aspect-weaving stuff? That would be super helpful.

`Feb 01, 2017 6:18:04 PM com.sun.jersey.spi.container.ContainerResponse mapMappableContainerException
SEVERE: The exception contained within MappableContainerException could not be mapped to a response, re-throwing to the HTTP container
java.lang.AbstractMethodError: org.hibernate.validator.internal.engine.ValidatorImpl.forExecutables()Ljavax/validation/executable/ExecutableValidator;
	at com.jcabi.aspects.aj.MethodValidator.validateMethod(MethodValidator.java:155)
	at com.jcabi.aspects.aj.MethodValidator.beforeMethod(MethodValidator.java:87)
	at mypackage.AuthResource.login(AuthResource.java:88)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
	at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205)
	at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
	at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302)
	at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
	at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
	at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
	at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
	at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1542)
	at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1473)
	at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1419)
	at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1409)
	at com.sun.jersey.server.impl.container.grizzly2.GrizzlyContainer._service(GrizzlyContainer.java:222)
	at com.sun.jersey.server.impl.container.grizzly2.GrizzlyContainer.service(GrizzlyContainer.java:192)
	at org.glassfish.grizzly.http.server.HttpHandler$1.run(HttpHandler.java:224)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
	at java.lang.Thread.run(Thread.java:744)`

@cobbzilla
Copy link
Author

@yegor256 just pinging, would love to use your library but am still stuck here.

@yegor256
Copy link
Member

yegor256 commented Jul 10, 2017

@cobbzilla it seems that you have two validating engines in the classpath. You should exclude hibernate-validator and try again. Most probably it's coming together with one of jcabi dependencies, but I'm not sure. Check the list of your deps and exclude it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants