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

Jersey2.26 - Cdi2 don't work with BeanValidation #3753

Open
jerseyrobot opened this issue Jan 8, 2018 · 8 comments
Open

Jersey2.26 - Cdi2 don't work with BeanValidation #3753

jerseyrobot opened this issue Jan 8, 2018 · 8 comments
Milestone

Comments

@jerseyrobot
Copy link
Contributor

I configured Grizzly + Jersey2 and I started to use "jersey-cdi2-se" but when jersey-bean-validation is included, it didn't work

First, at compile time I getting this Error

Exception in thread "main" java.lang.IllegalArgumentException: Can not set javax.validation.ValidatorFactory field org.glassfish.jersey.server.validation.internal.ValidationBinder$ConfiguredValidatorProvider.factory to org.hibernate.validator.internal.engine.ConfigurationImpl at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167) at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171) at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:81) at java.lang.reflect.Field.set(Field.java:764) at org.jboss.weld.injection.FieldInjectionPoint.inject(FieldInjectionPoint.java:94) at org.jboss.weld.util.Beans.injectBoundFields(Beans.java:335) at org.jboss.weld.util.Beans.injectFieldsAndInitializers(Beans.java:346) at org.jboss.weld.injection.producer.ResourceInjector$1.proceed(ResourceInjector.java:69) at org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:48) at org.jboss.weld.injection.producer.ResourceInjector.inject(ResourceInjector.java:71) at org.jboss.weld.injection.producer.BasicInjectionTarget.inject(BasicInjectionTarget.java:117) at org.glassfish.jersey.inject.cdi.se.injector.JerseyInjectionTarget.inject(JerseyInjectionTarget.java:171) at org.glassfish.jersey.inject.cdi.se.bean.SupplierClassBean.create(SupplierClassBean.java:127) at org.glassfish.jersey.inject.cdi.se.bean.SupplierClassBean.create(SupplierClassBean.java:89) at org.jboss.weld.contexts.AbstractContext.get(AbstractContext.java:96) at org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.get(ContextualInstanceStrategy.java:100) at org.jboss.weld.bean.ContextualInstance.get(ContextualInstance.java:50) at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:676) at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:699) at org.jboss.weld.util.ForwardingBeanManager.getReference(ForwardingBeanManager.java:64) at org.jboss.weld.bean.builtin.BeanManagerProxy.getReference(BeanManagerProxy.java:86) at org.glassfish.jersey.inject.cdi.se.bean.SupplierBeanBridge.getSupplier(SupplierBeanBridge.java:162) at org.glassfish.jersey.inject.cdi.se.bean.SupplierBeanBridge.create(SupplierBeanBridge.java:133) at org.jboss.weld.contexts.unbound.DependentContextImpl.get(DependentContextImpl.java:70) at org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.get(ContextualInstanceStrategy.java:100) at org.jboss.weld.bean.ContextualInstance.get(ContextualInstance.java:50) at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:676) at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:699) at org.jboss.weld.util.ForwardingBeanManager.getReference(ForwardingBeanManager.java:64) at org.jboss.weld.bean.builtin.BeanManagerProxy.getReference(BeanManagerProxy.java:86) at org.glassfish.jersey.inject.cdi.se.CdiSeInjectionManager.getInstanceInternal(CdiSeInjectionManager.java:183) at org.glassfish.jersey.inject.cdi.se.CdiSeInjectionManager.getInstance(CdiSeInjectionManager.java:166) at org.glassfish.jersey.server.model.internal.ResourceMethodInvokerConfigurator.lambda$postInit$0(ResourceMethodInvokerConfigurator.java:78) at org.glassfish.jersey.server.model.ResourceMethodInvoker$Builder.build(ResourceMethodInvoker.java:218) at org.glassfish.jersey.server.internal.routing.RuntimeModelBuilder.createInflector(RuntimeModelBuilder.java:130) at org.glassfish.jersey.server.internal.routing.RuntimeModelBuilder.createMethodRouter(RuntimeModelBuilder.java:117) at org.glassfish.jersey.server.internal.routing.RuntimeModelBuilder.createResourceMethodRouters(RuntimeModelBuilder.java:311) at org.glassfish.jersey.server.internal.routing.RuntimeModelBuilder.buildModel(RuntimeModelBuilder.java:200) at org.glassfish.jersey.server.internal.routing.Routing$Builder.buildStage(Routing.java:247) at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:422) at org.glassfish.jersey.server.ApplicationHandler.lambda$initialize$1(ApplicationHandler.java:316) at org.glassfish.jersey.internal.Errors.process(Errors.java:316) at org.glassfish.jersey.internal.Errors.process(Errors.java:298) at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:256) at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:315) at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:282) at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:269) at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer.<init>(GrizzlyHttpContainer.java:334) at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory.createHttpServer(GrizzlyHttpServerFactory.java:117)

I tried to register org.glassfish.jersey.server.validation.internal.ValidationBinder and the error disappears but bean validation is ignored and the service doesn't work.

If I use jersey-hk2 bean validation start to work but without CDI.

@jerseyrobot
Copy link
Contributor Author

@SamuelHyman Commented
Having the exact same issue. Any workarounds that enable CDI?

@jerseyrobot
Copy link
Contributor Author

@sburlyaev Commented
the same...

@jerseyrobot
Copy link
Contributor Author

@jmflausino
Copy link

jmflausino commented Aug 1, 2018

Same problem here, but with Jersey 2.27

@xak2000
Copy link

xak2000 commented Dec 14, 2018

Same here. Just adding this dependency

        <dependency>
            <groupId>org.glassfish.jersey.ext</groupId>
            <artifactId>jersey-bean-validation</artifactId>
        </dependency>

into helloworld-cdi2-se example breaks it and throws

"Hello World" Jersey Example App
дек 14, 2018 9:11:01 PM org.jboss.weld.bootstrap.WeldStartup <clinit>
INFO: WELD-000900: 3.0.0 (Final)
дек 14, 2018 9:11:01 PM org.jboss.weld.bootstrap.WeldStartup startContainer
INFO: WELD-000101: Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked synchronously.
дек 14, 2018 9:11:02 PM org.jboss.weld.environment.se.WeldContainer fireContainerInitializedEvent
INFO: WELD-ENV-002003: Weld SE container 24c2afeb-1d87-4739-8b2a-fefc2f211b41 initialized
дек 14, 2018 9:11:02 PM org.hibernate.validator.internal.util.Version <clinit>
INFO: HV000001: Hibernate Validator 5.1.3.Final
Exception in thread "main" java.lang.IllegalArgumentException: Can not set javax.validation.ValidatorFactory field org.glassfish.jersey.server.validation.internal.ValidationBinder$ConfiguredValidatorProvider.factory to org.hibernate.validator.internal.engine.ConfigurationImpl
	at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167)
	at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171)
	at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:81)
	at java.lang.reflect.Field.set(Field.java:764)
	at org.jboss.weld.injection.FieldInjectionPoint.inject(FieldInjectionPoint.java:94)
	at org.jboss.weld.util.Beans.injectBoundFields(Beans.java:335)
	at org.jboss.weld.util.Beans.injectFieldsAndInitializers(Beans.java:346)
	at org.jboss.weld.injection.producer.ResourceInjector$1.proceed(ResourceInjector.java:69)
	at org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:48)
	at org.jboss.weld.injection.producer.ResourceInjector.inject(ResourceInjector.java:71)
	at org.jboss.weld.injection.producer.BasicInjectionTarget.inject(BasicInjectionTarget.java:117)
	at org.glassfish.jersey.inject.cdi.se.injector.JerseyInjectionTarget.inject(JerseyInjectionTarget.java:171)
	at org.glassfish.jersey.inject.cdi.se.bean.SupplierClassBean.create(SupplierClassBean.java:127)
	at org.glassfish.jersey.inject.cdi.se.bean.SupplierClassBean.create(SupplierClassBean.java:89)
	at org.jboss.weld.contexts.AbstractContext.get(AbstractContext.java:96)
	at org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.get(ContextualInstanceStrategy.java:100)
	at org.jboss.weld.bean.ContextualInstance.get(ContextualInstance.java:50)
	at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:676)
	at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:699)
	at org.jboss.weld.util.ForwardingBeanManager.getReference(ForwardingBeanManager.java:64)
	at org.jboss.weld.bean.builtin.BeanManagerProxy.getReference(BeanManagerProxy.java:86)
	at org.glassfish.jersey.inject.cdi.se.bean.SupplierBeanBridge.getSupplier(SupplierBeanBridge.java:162)
	at org.glassfish.jersey.inject.cdi.se.bean.SupplierBeanBridge.create(SupplierBeanBridge.java:133)
	at org.jboss.weld.contexts.unbound.DependentContextImpl.get(DependentContextImpl.java:70)
	at org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.get(ContextualInstanceStrategy.java:100)
	at org.jboss.weld.bean.ContextualInstance.get(ContextualInstance.java:50)
	at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:676)
	at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:699)
	at org.jboss.weld.util.ForwardingBeanManager.getReference(ForwardingBeanManager.java:64)
	at org.jboss.weld.bean.builtin.BeanManagerProxy.getReference(BeanManagerProxy.java:86)
	at org.glassfish.jersey.inject.cdi.se.CdiSeInjectionManager.getInstanceInternal(CdiSeInjectionManager.java:183)
	at org.glassfish.jersey.inject.cdi.se.CdiSeInjectionManager.getInstance(CdiSeInjectionManager.java:166)
	at org.glassfish.jersey.server.model.internal.ResourceMethodInvokerConfigurator.lambda$postInit$0(ResourceMethodInvokerConfigurator.java:78)
	at org.glassfish.jersey.server.model.ResourceMethodInvoker$Builder.build(ResourceMethodInvoker.java:218)
	at org.glassfish.jersey.server.internal.routing.RuntimeModelBuilder.createInflector(RuntimeModelBuilder.java:130)
	at org.glassfish.jersey.server.internal.routing.RuntimeModelBuilder.createMethodRouter(RuntimeModelBuilder.java:117)
	at org.glassfish.jersey.server.internal.routing.RuntimeModelBuilder.createResourceMethodRouters(RuntimeModelBuilder.java:311)
	at org.glassfish.jersey.server.internal.routing.RuntimeModelBuilder.buildModel(RuntimeModelBuilder.java:175)
	at org.glassfish.jersey.server.internal.routing.Routing$Builder.buildStage(Routing.java:247)
	at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:422)
	at org.glassfish.jersey.server.ApplicationHandler.lambda$initialize$1(ApplicationHandler.java:316)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:316)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:298)
	at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:256)
	at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:315)
	at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:282)
	at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:269)
	at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer.<init>(GrizzlyHttpContainer.java:334)
	at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory.createHttpServer(GrizzlyHttpServerFactory.java:138)
	at org.glassfish.jersey.examples.helloworld.cdi2se.App.main(App.java:69)

@pa314159
Copy link
Contributor

pa314159 commented Aug 8, 2019

I have created a PR for this issue
#4219

pa314159 added a commit to pa314159/jersey that referenced this issue Aug 28, 2019
Changes in issue eclipse-ee4j#4208 resolved the IllegalArgumentException, however
bean validation doesn't work.
pa314159 added a commit to pa314159/jersey that referenced this issue Aug 28, 2019
pa314159 added a commit to pa314159/jersey that referenced this issue Aug 28, 2019
pa314159 added a commit to pa314159/jersey that referenced this issue Aug 28, 2019
Changes in issue eclipse-ee4j#4208 resolved the IllegalArgumentException, however
bean validation doesn't work.
pa314159 added a commit to pa314159/jersey that referenced this issue Aug 28, 2019
pa314159 added a commit to pa314159/jersey that referenced this issue Aug 28, 2019
pa314159 added a commit to pa314159/jersey that referenced this issue Aug 28, 2019
Changes in issue eclipse-ee4j#4208 resolved the IllegalArgumentException, however
bean validation doesn't work.
pa314159 added a commit to pa314159/jersey that referenced this issue Aug 28, 2019
pa314159 added a commit to pa314159/jersey that referenced this issue Aug 28, 2019
pa314159 added a commit to pa314159/jersey that referenced this issue Aug 28, 2019
Changes in issue eclipse-ee4j#4208 resolved the IllegalArgumentException, however
bean validation doesn't work.
pa314159 added a commit to pa314159/jersey that referenced this issue Aug 28, 2019
pa314159 added a commit to pa314159/jersey that referenced this issue Aug 28, 2019
pa314159 added a commit to pa314159/jersey that referenced this issue Aug 28, 2019
Changes in issue eclipse-ee4j#4208 resolved the IllegalArgumentException, however
bean validation doesn't work.

Signed-off-by: pappy <[email protected]>
pa314159 added a commit to pa314159/jersey that referenced this issue Aug 28, 2019
pa314159 added a commit to pa314159/jersey that referenced this issue Aug 28, 2019
pa314159 added a commit to pa314159/jersey that referenced this issue Aug 28, 2019
Changes in issue eclipse-ee4j#4208 resolved the IllegalArgumentException, however
bean validation doesn't work.

Signed-off-by: pappy <[email protected]>
pa314159 added a commit to pa314159/jersey that referenced this issue Aug 28, 2019
pa314159 added a commit to pa314159/jersey that referenced this issue Aug 28, 2019
pa314159 added a commit to pa314159/jersey that referenced this issue Aug 28, 2019
Changes in issue eclipse-ee4j#4208 resolved the IllegalArgumentException, however
bean validation doesn't work.

Signed-off-by: pappy <[email protected]>
pa314159 added a commit to pa314159/jersey that referenced this issue Aug 28, 2019
pa314159 added a commit to pa314159/jersey that referenced this issue Aug 28, 2019
pa314159 added a commit to pa314159/jersey that referenced this issue Aug 28, 2019
Changes in issue eclipse-ee4j#4208 resolved the IllegalArgumentException, however
bean validation doesn't work.

Signed-off-by: pappy <[email protected]>
pa314159 added a commit to pa314159/jersey that referenced this issue Aug 28, 2019
pa314159 added a commit to pa314159/jersey that referenced this issue Aug 28, 2019
pa314159 added a commit to pa314159/jersey that referenced this issue Aug 30, 2019
Changes in issue eclipse-ee4j#4208 resolved the IllegalArgumentException, however
bean validation doesn't work.

Signed-off-by: pappy <[email protected]>
pa314159 added a commit to pa314159/jersey that referenced this issue Aug 30, 2019
pa314159 added a commit to pa314159/jersey that referenced this issue Aug 30, 2019
pa314159 added a commit to pa314159/jersey that referenced this issue Aug 30, 2019
Changes in issue eclipse-ee4j#4208 resolved the IllegalArgumentException, however
bean validation doesn't work.

Signed-off-by: pappy <[email protected]>
pa314159 added a commit to pa314159/jersey that referenced this issue Aug 30, 2019
pa314159 added a commit to pa314159/jersey that referenced this issue Sep 3, 2019
Changes in issue eclipse-ee4j#4208 resolved the IllegalArgumentException, however
bean validation doesn't work.

Signed-off-by: pappy <[email protected]>
pa314159 added a commit to pa314159/jersey that referenced this issue Sep 3, 2019
pa314159 added a commit to pa314159/jersey that referenced this issue Sep 5, 2019
Changes in issue eclipse-ee4j#4208 resolved the IllegalArgumentException, however
bean validation doesn't work.

Signed-off-by: pappy <[email protected]>
pa314159 added a commit to pa314159/jersey that referenced this issue Sep 5, 2019
pa314159 added a commit to pa314159/jersey that referenced this issue Sep 9, 2019
Changes in issue eclipse-ee4j#4208 resolved the IllegalArgumentException, however
bean validation doesn't work.

Signed-off-by: pappy <[email protected]>
pa314159 added a commit to pa314159/jersey that referenced this issue Sep 9, 2019
pa314159 added a commit to pa314159/jersey that referenced this issue Oct 2, 2019
Changes in issue eclipse-ee4j#4208 resolved the IllegalArgumentException, however
bean validation doesn't work.

Signed-off-by: pappy <[email protected]>
pa314159 added a commit to pa314159/jersey that referenced this issue Oct 2, 2019
pa314159 added a commit to pa314159/jersey that referenced this issue Oct 4, 2019
Changes in issue eclipse-ee4j#4208 resolved the IllegalArgumentException, however
bean validation doesn't work.

Signed-off-by: pappy <[email protected]>
pa314159 added a commit to pa314159/jersey that referenced this issue Oct 4, 2019
pa314159 added a commit to pa314159/jersey that referenced this issue Oct 18, 2019
Changes in issue eclipse-ee4j#4208 resolved the IllegalArgumentException, however
bean validation doesn't work.

Signed-off-by: pappy <[email protected]>
pa314159 added a commit to pa314159/jersey that referenced this issue Oct 18, 2019
pa314159 added a commit to pa314159/jersey that referenced this issue Oct 24, 2019
Changes in issue eclipse-ee4j#4208 resolved the IllegalArgumentException, however
bean validation doesn't work.

Signed-off-by: pappy <[email protected]>
pa314159 added a commit to pa314159/jersey that referenced this issue Oct 24, 2019
pa314159 added a commit to pa314159/jersey that referenced this issue Oct 27, 2019
Changes in issue eclipse-ee4j#4208 resolved the IllegalArgumentException, however
bean validation doesn't work.

Signed-off-by: pappy <[email protected]>
pa314159 added a commit to pa314159/jersey that referenced this issue Oct 27, 2019
@jsikkes
Copy link

jsikkes commented Jan 15, 2020

We are currently experiencing this same issue in Jersey 2.30

Pull request #4219, which should resolve it, was originally waiting for the merge of #4236. Which is done in 2.29.1.

I was wondering if #4219 is still in view and if it can be merged in a next release.

@jansupol jansupol added this to the 2.31 milestone Jan 15, 2020
@pa314159
Copy link
Contributor

@jsikkes, AFAIR , that PR was closed because the tests that pass on my system fail on Travis.

pa314159 added a commit to pa314159/jersey that referenced this issue Jan 22, 2020
Changes in issue eclipse-ee4j#4208 resolved the IllegalArgumentException, however
bean validation doesn't work.

Signed-off-by: pappy <[email protected]>
pa314159 added a commit to pa314159/jersey that referenced this issue Jan 22, 2020
pa314159 added a commit to pa314159/jersey that referenced this issue Mar 10, 2020
Changes in issue eclipse-ee4j#4208 resolved the IllegalArgumentException, however
bean validation doesn't work.

Signed-off-by: pappy <[email protected]>
pa314159 added a commit to pa314159/jersey that referenced this issue Mar 10, 2020
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

6 participants