title: Does Jersey Extension for Bean Validation supports Bean Validation 2.0 (JSR 380)
body: <p>I am working with <strong>WebSphere Liberty 19.0.0.2</strong> with <strong>webProfile-8.0</strong> feature which supports <strong>jaxrs-2.1</strong> and <strong>beanValidation-2.0.</strong> For better support for MutiPart streaming I am using Jersey as JAX-RS implementation instead of liberty's default Apache CXF.</p>
  
  <p>Some more contextual information about versioning of relevant components</p>
  
  <blockquote>
    <p>Bean Validation 1.1 (JSR 349), Bean Validation 2.0 (JSR 380)</p>
  </blockquote>
  
  <p>I want to use <strong>bean validation 2.0</strong> feature to validate request/response/params in my REST Resource class and for that I need use Jersey's extension for bean validation. <a href="https://eclipse-ee4j.github.io/jersey.github.io/documentation/latest/bean-validation.html" rel="nofollow noreferrer">https://eclipse-ee4j.github.io/jersey.github.io/documentation/latest/bean-validation.html</a> </p>
  
  <p>As you can see on this link (if you scroll down) the latest version of the extension (2.30.1) also refer to JSR-349 which is bean validation 1.1. </p>
  
  <p>MENIFEST of the jar from following gradle dependency also mention JSR-349</p>
  
  <pre><code>compile group: 'org.glassfish.jersey.ext', name: 'jersey-bean-validation', version: '2.30'
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/DDhbx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DDhbx.png" alt="enter image description here"></a></p>
  
  <p>Its surprising that there is no Jersey extension for Bean Validation 2.0 (JSR 380).</p>
  
  <p>When I use above dependency in liberty, bean validation works but I get following error on server startup because of bean validation annotation usage in my resource class. </p>
  
  <pre><code>[3/5/20 18:11:28:597 EST] 00000020 id=00000000 org.glassfish.jersey.model.Parameter                         2 Unable to get the com.sun.proxy.$Proxy70 annotation value property
  java.lang.NoSuchMethodException: javax.validation.constraints.NotNull.value()
      at java.lang.Class.getMethod(Class.java:1786)
      at org.glassfish.jersey.model.Parameter.getValue(Parameter.java:453)
      at org.glassfish.jersey.model.Parameter.create(Parameter.java:270)
      at org.glassfish.jersey.model.Parameter.createList(Parameter.java:400)
      at org.glassfish.jersey.model.Parameter.createList(Parameter.java:383)
      at org.glassfish.jersey.server.model.Parameter.create(Parameter.java:137)
      at org.glassfish.jersey.server.model.Invocable.&lt;init&gt;(Invocable.java:215)
      at org.glassfish.jersey.server.model.Invocable.create(Invocable.java:161)
      at org.glassfish.jersey.server.model.ResourceMethod$Builder.createInvocable(ResourceMethod.java:541)
      at org.glassfish.jersey.server.model.ResourceMethod$Builder.build(ResourceMethod.java:522)
      at org.glassfish.jersey.server.model.Resource$Builder.processMethodBuilders(Resource.java:647)
      at org.glassfish.jersey.server.model.Resource$Builder.buildResourceData(Resource.java:583)
      at org.glassfish.jersey.server.model.Resource$Builder.build(Resource.java:639)
      at org.glassfish.jersey.server.model.Resource.from(Resource.java:782)
      at org.glassfish.jersey.server.ResourceBagConfigurator.init(ResourceBagConfigurator.java:55)
      at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:331)
      at org.glassfish.jersey.server.ApplicationHandler.lambda$initialize$1(ApplicationHandler.java:293)
      at org.glassfish.jersey.internal.Errors.process(Errors.java:292)
      at org.glassfish.jersey.internal.Errors.process(Errors.java:274)
      at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:232)
      at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:292)
      at org.glassfish.jersey.server.ApplicationHandler.&lt;init&gt;(ApplicationHandler.java:259)
      at org.glassfish.jersey.servlet.WebComponent.&lt;init&gt;(WebComponent.java:311)
      at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:154)
      at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:347)
      at javax.servlet.GenericServlet.init(GenericServlet.java:244)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:291)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.loadOnStartupCheck(ServletWrapper.java:1373)
      at com.ibm.ws.webcontainer.webapp.WebApp.doLoadOnStartupActions(WebApp.java:1157)
      at com.ibm.ws.webcontainer.webapp.WebApp.commonInitializationFinally(WebApp.java:1125)
      at com.ibm.ws.webcontainer.webapp.WebApp.initialize(WebApp.java:1023)
      at com.ibm.ws.webcontainer.webapp.WebApp.initialize(WebApp.java:6619)
      at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost.startWebApp(DynamicVirtualHost.java:467)
      at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost.startWebApplication(DynamicVirtualHost.java:462)
      at com.ibm.ws.webcontainer.osgi.WebContainer.startWebApplication(WebContainer.java:1152)
      at com.ibm.ws.webcontainer.osgi.WebContainer.access$000(WebContainer.java:111)
      at com.ibm.ws.webcontainer.osgi.WebContainer$3.run(WebContainer.java:957)
      at com.ibm.ws.threading.internal.ExecutorServiceImpl$RunnableWrapper.run(ExecutorServiceImpl.java:239)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:745)
  
  [3/5/20 18:11:28:598 EST] 00000020 id=00000000 org.glassfish.jersey.model.Parameter                         2 Unable to get the com.sun.proxy.$Proxy29 annotation value property
  java.lang.NoSuchMethodException: javax.validation.Valid.value()
      at java.lang.Class.getMethod(Class.java:1786)
      at org.glassfish.jersey.model.Parameter.getValue(Parameter.java:453)
      at org.glassfish.jersey.model.Parameter.create(Parameter.java:270)
      at org.glassfish.jersey.model.Parameter.createList(Parameter.java:400)
      at org.glassfish.jersey.model.Parameter.createList(Parameter.java:383)
      at org.glassfish.jersey.server.model.Parameter.create(Parameter.java:137)
      at org.glassfish.jersey.server.model.Invocable.&lt;init&gt;(Invocable.java:215)
      at org.glassfish.jersey.server.model.Invocable.create(Invocable.java:161)
      at org.glassfish.jersey.server.model.ResourceMethod$Builder.createInvocable(ResourceMethod.java:541)
      at org.glassfish.jersey.server.model.ResourceMethod$Builder.build(ResourceMethod.java:522)
      at org.glassfish.jersey.server.model.Resource$Builder.processMethodBuilders(Resource.java:647)
  </code></pre>
  
  <p>These error are concerning and not feeling confident to use it. Any advice or help is much appreciated.</p>
  
  <p><strong>Update 03/06/2020</strong>
  Following is feature manager section from server.xml</p>
  
  <pre><code>&lt;featureManager&gt;
      &lt;!--NOTE: Following are standard features and should not be removed--&gt;
      &lt;feature&gt;servlet-4.0&lt;/feature&gt;
      &lt;feature&gt;jndi-1.0&lt;/feature&gt;
      &lt;feature&gt;requestTiming-1.0&lt;/feature&gt;
      &lt;feature&gt;monitor-1.0&lt;/feature&gt;
      &lt;feature&gt;localConnector-1.0&lt;/feature&gt;
      &lt;feature&gt;restConnector-2.0&lt;/feature&gt;
      &lt;feature&gt;ssl-1.0&lt;/feature&gt;
  
      &lt;!-- Do not add enabled webProfile-8.0 because we want to disable default 
      REST implementation (Apache-CXF) provided by Liberty. We want to use Jersey 
      as our REST implementation because it better support multi-part streaming, --&gt;
      &lt;!-- &lt;feature&gt;webProfile-8.0&lt;/feature&gt; --&gt;
      &lt;feature&gt;jsp-2.3&lt;/feature&gt;
      &lt;feature&gt;cdi-2.0&lt;/feature&gt;
      &lt;feature&gt;managedBeans-1.0&lt;/feature&gt;
      &lt;feature&gt;jdbc-4.2&lt;/feature&gt;
      &lt;feature&gt;beanValidation-2.0&lt;/feature&gt;
      &lt;!-- We need javaMail feature for logback email appender to work --&gt;
      &lt;feature&gt;javaMail-1.6&lt;/feature&gt;
  &lt;/featureManager&gt;
  </code></pre>
  
  <p>Here is my rest application configuration extending jersey's ResourceConfig class</p>
  
  <pre><code>import javax.ws.rs.ApplicationPath;
  
  import org.glassfish.jersey.logging.LoggingFeature;
  import org.glassfish.jersey.media.multipart.MultiPartFeature;
  import org.glassfish.jersey.server.ResourceConfig;
  import org.glassfish.jersey.server.ServerProperties;
  
  @ApplicationPath("/rest")
  public class RestApplicationConfig extends ResourceConfig {
  
      public RestApplicationConfig() {
          super();
          configureResourcesAndFeatures();
      }
  
      private void configureResourcesAndFeatures() {
          packages(RestApplicationConfig.class.getPackage().getName());
          register(MultiPartFeature.class);
  
          property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true);
      }
  }
  </code></pre>
  
  <p>I mentioned use of jersey-bean-validation version 2.30 but I learned that <strong>Jersey 2.27 is latest version which is JAVA EE implementation of JAX-RS 2.1 API. Starting 2.28 its Jakarta EE implementation of JAX-RS 2.1</strong>. So I would really want to use version 2.27 and make bean validation 2.0 working with it because liberty version I am using has not up to jakarta ee yet.</p>