Let Jackson use JAXB3 (#4963)

* Let Jackson use JAXB3
Keep optional dependency for JAXB2 to keep it working

Signed-off-by: jansupol <jan.supol@oracle.com>
diff --git a/examples/json-jackson/src/main/java/org/glassfish/jersey/examples/jackson/CombinedAnnotationBean.java b/examples/json-jackson/src/main/java/org/glassfish/jersey/examples/jackson/CombinedAnnotationBean.java
index 06a23c4..2ac0ac6 100644
--- a/examples/json-jackson/src/main/java/org/glassfish/jersey/examples/jackson/CombinedAnnotationBean.java
+++ b/examples/json-jackson/src/main/java/org/glassfish/jersey/examples/jackson/CombinedAnnotationBean.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2022 Oracle and/or its affiliates. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Distribution License v. 1.0, which is available at
@@ -10,7 +10,7 @@
 
 package org.glassfish.jersey.examples.jackson;
 
-import javax.xml.bind.annotation.XmlRootElement;
+import jakarta.xml.bind.annotation.XmlRootElement;
 
 import com.fasterxml.jackson.annotation.JsonProperty;
 
diff --git a/examples/json-jackson/src/main/java/org/glassfish/jersey/examples/jackson/MyObjectMapperProvider.java b/examples/json-jackson/src/main/java/org/glassfish/jersey/examples/jackson/MyObjectMapperProvider.java
index e321358..81bda85 100644
--- a/examples/json-jackson/src/main/java/org/glassfish/jersey/examples/jackson/MyObjectMapperProvider.java
+++ b/examples/json-jackson/src/main/java/org/glassfish/jersey/examples/jackson/MyObjectMapperProvider.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2022 Oracle and/or its affiliates. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Distribution License v. 1.0, which is available at
@@ -19,7 +19,7 @@
 import com.fasterxml.jackson.databind.SerializationFeature;
 import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
 import com.fasterxml.jackson.databind.type.TypeFactory;
-import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector;
+import com.fasterxml.jackson.module.jakarta.xmlbind.JakartaXmlBindAnnotationIntrospector;
 
 /**
  * TODO javadoc.
@@ -63,7 +63,7 @@
 
     private static AnnotationIntrospector createJaxbJacksonAnnotationIntrospector() {
 
-        final AnnotationIntrospector jaxbIntrospector = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance());
+        final AnnotationIntrospector jaxbIntrospector = new JakartaXmlBindAnnotationIntrospector(TypeFactory.defaultInstance());
         final AnnotationIntrospector jacksonIntrospector = new JacksonAnnotationIntrospector();
 
         return AnnotationIntrospector.pair(jacksonIntrospector, jaxbIntrospector);
diff --git a/media/json-jackson/pom.xml b/media/json-jackson/pom.xml
index cbc0177..9456ee6 100644
--- a/media/json-jackson/pom.xml
+++ b/media/json-jackson/pom.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 
-    Copyright (c) 2012, 2021 Oracle and/or its affiliates. All rights reserved.
+    Copyright (c) 2012, 2022 Oracle and/or its affiliates. All rights reserved.
 
     This program and the accompanying materials are made available under the
     terms of the Eclipse Public License v. 2.0, which is available at
@@ -131,13 +131,34 @@
                     <artifactId>jakarta.activation-api</artifactId>
                 </exclusion>
             </exclusions>
+            <optional>true</optional>
+            <scope>provided</scope>
         </dependency>
         <dependency>
-            <!-- The last JAX-B API that has maven coordinates which do not colide with Jakarta coordinates -->
+            <groupId>com.fasterxml.jackson.module</groupId>
+            <artifactId>jackson-module-jakarta-xmlbind-annotations</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>jakarta.xml.bind</groupId>
+                    <artifactId>jakarta.xml.bind-api</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>jakarta.activation</groupId>
+                    <artifactId>jakarta.activation-api</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <!-- The last JAX-B API that has maven coordinates which do not collide with Jakarta coordinates -->
             <!-- Do not update -->
             <groupId>javax.xml.bind</groupId>
             <artifactId>jaxb-api</artifactId>
             <version>2.3.1</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>jakarta.xml.bind</groupId>
+            <artifactId>jakarta.xml.bind-api</artifactId>
         </dependency>
         <dependency>
             <groupId>junit</groupId>
diff --git a/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/DefaultJacksonJaxbJsonProvider.java b/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/DefaultJacksonJaxbJsonProvider.java
index 2ad04c1..f4f0f3f 100644
--- a/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/DefaultJacksonJaxbJsonProvider.java
+++ b/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/DefaultJacksonJaxbJsonProvider.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2022 Oracle and/or its affiliates. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0, which is available at
@@ -31,15 +31,15 @@
 public class DefaultJacksonJaxbJsonProvider extends JacksonJaxbJsonProvider {
 
     //do not register JaxbAnnotationModule because it brakes default annotations processing
-    private static final String EXCLUDE_MODULE_NAME = "JaxbAnnotationModule";
+    private static final String[] EXCLUDE_MODULE_NAMES = {"JaxbAnnotationModule", "JakartaXmlBindAnnotationModule"};
 
     public DefaultJacksonJaxbJsonProvider() {
-        super();
+        super(new JacksonMapperConfigurator(null, DEFAULT_ANNOTATIONS));
         findAndRegisterModules();
     }
 
     public DefaultJacksonJaxbJsonProvider(final Annotations... annotationsToUse) {
-        super(annotationsToUse);
+        super(new JacksonMapperConfigurator(null, annotationsToUse));
         findAndRegisterModules();
     }
 
@@ -49,7 +49,9 @@
         final ObjectMapper mapper = _mapperConfig.getConfiguredMapper();
 
         final List<Module> modules = ObjectMapper.findModules();
-        modules.removeIf(mod -> mod.getModuleName().contains(EXCLUDE_MODULE_NAME));
+        for (String exludeModuleName : EXCLUDE_MODULE_NAMES) {
+            modules.removeIf(mod -> mod.getModuleName().contains(exludeModuleName));
+        }
 
         defaultMapper.registerModules(modules);
         if (mapper != null) {
diff --git a/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/JacksonMapperConfigurator.java b/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/JacksonMapperConfigurator.java
new file mode 100644
index 0000000..7be7b11
--- /dev/null
+++ b/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/JacksonMapperConfigurator.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.jersey.jackson.internal;
+
+import com.fasterxml.jackson.databind.AnnotationIntrospector;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.module.jakarta.xmlbind.JakartaXmlBindAnnotationIntrospector;
+import org.glassfish.jersey.internal.util.ReflectionHelper;
+import org.glassfish.jersey.internal.util.collection.LazyValue;
+import org.glassfish.jersey.internal.util.collection.Value;
+import org.glassfish.jersey.internal.util.collection.Values;
+import org.glassfish.jersey.jackson.internal.jackson.jaxrs.cfg.Annotations;
+import org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JsonMapperConfigurator;
+
+import java.security.AccessController;
+import java.util.ArrayList;
+
+public class JacksonMapperConfigurator extends JsonMapperConfigurator {
+    public JacksonMapperConfigurator(ObjectMapper mapper, Annotations[] defAnnotations) {
+        super(mapper, defAnnotations);
+    }
+
+    @Override
+    protected AnnotationIntrospector _resolveIntrospectors(Annotations[] annotationsToUse) {
+        // Let's ensure there are no dups there first, filter out nulls
+        ArrayList<AnnotationIntrospector> intr = new ArrayList<AnnotationIntrospector>();
+        for (Annotations a : annotationsToUse) {
+            if (a != null) {
+                _resolveIntrospector(a, intr);
+            }
+        }
+        int count = intr.size();
+        if (count == 0) {
+            return AnnotationIntrospector.nopInstance();
+        }
+        AnnotationIntrospector curr = intr.get(0);
+        for (int i = 1, len = intr.size(); i < len; ++i) {
+            curr = AnnotationIntrospector.pair(curr, intr.get(i));
+        }
+        return curr;
+    }
+
+    protected void _resolveIntrospector(Annotations ann, ArrayList<AnnotationIntrospector> intr) {
+        switch (ann) {
+            case JAXB:
+                /* For this, need to use indirection just so that error occurs
+                 * when we get here, and not when this class is being loaded
+                 */
+                try {
+                    if (_jaxbIntrospectorClass == null) {
+                        _jaxbIntrospectorClass = JakartaXmlBindAnnotationIntrospector.class;
+                    }
+                    intr.add(JakartaXmlBindAnnotationIntrospector.class.newInstance());
+                } catch (Exception e) {
+                    throw new IllegalStateException("Failed to instantiate JakartaXmlBindAnnotationIntrospector: "
+                            + e.getMessage(), e);
+                }
+
+                if (jaxb2AnnotationIntrospector.get() == true) {
+                    Class<? extends AnnotationIntrospector> tempJaxbIntrospectorClass = _jaxbIntrospectorClass;
+                    _jaxbIntrospectorClass = null;
+                    intr.add(super._resolveIntrospector(ann));
+                    _jaxbIntrospectorClass = tempJaxbIntrospectorClass;
+                }
+                break;
+            default:
+                intr.add(super._resolveIntrospector(ann));
+        }
+    }
+
+    private static LazyValue<Boolean> jaxb2AnnotationIntrospector = Values.lazy((Value<Boolean>) () -> {
+        final Class<?> aClass = AccessController.doPrivileged(
+                ReflectionHelper.classForNamePA("com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector")
+        );
+        return aClass != null;
+    });
+}
diff --git a/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/json/JacksonJaxbJsonProvider.java b/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/json/JacksonJaxbJsonProvider.java
index 1c0a882..eb7c072 100644
--- a/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/json/JacksonJaxbJsonProvider.java
+++ b/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/json/JacksonJaxbJsonProvider.java
@@ -63,4 +63,10 @@
     {
         super(mapper, annotationsToUse);
     }
+
+    // Do not erase - Jersey required constructor
+    protected JacksonJaxbJsonProvider(JsonMapperConfigurator configurator)
+    {
+        super(configurator);
+    }
 }
diff --git a/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/json/JacksonJsonProvider.java b/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/json/JacksonJsonProvider.java
index 9fecf42..0871ece 100644
--- a/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/json/JacksonJsonProvider.java
+++ b/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/json/JacksonJsonProvider.java
@@ -137,6 +137,11 @@
         super(new JsonMapperConfigurator(mapper, annotationsToUse));
     }
 
+    // Do not erase - Jersey required constructor
+    protected JacksonJsonProvider(JsonMapperConfigurator configurator) {
+        super(configurator);
+    }
+
     /**
      * Method that will return version information stored in and read from jar
      * that contains this class.
diff --git a/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/JacksonJaxb2JsonProviderTest.java b/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/JacksonJaxb2JsonProviderTest.java
new file mode 100644
index 0000000..09a3c8b
--- /dev/null
+++ b/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/JacksonJaxb2JsonProviderTest.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.jersey.jackson.internal;
+
+import jakarta.ws.rs.core.Application;
+import org.glassfish.jersey.jackson.internal.model.Jaxb2ServiceTest;
+import org.glassfish.jersey.server.ResourceConfig;
+import org.glassfish.jersey.test.JerseyTest;
+import org.junit.Test;
+
+import static junit.framework.TestCase.assertEquals;
+
+public final class JacksonJaxb2JsonProviderTest extends JerseyTest {
+
+    @Override
+    protected final Application configure() {
+        return new ResourceConfig(Jaxb2ServiceTest.class);
+    }
+
+    @Test
+    public final void testJavaOptional() {
+        final String response = target("entity/simple").request().get(String.class);
+        assertEquals("{\"name\":\"Hello\",\"value\":\"World\"}", response);
+    }
+}
diff --git a/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/model/Jaxb2ServiceTest.java b/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/model/Jaxb2ServiceTest.java
new file mode 100644
index 0000000..a679142
--- /dev/null
+++ b/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/model/Jaxb2ServiceTest.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2020, 2022 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.jersey.jackson.internal.model;
+
+import com.fasterxml.jackson.annotation.JsonGetter;
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.core.MediaType;
+import javax.xml.bind.annotation.XmlElement;
+
+import java.util.Optional;
+
+@Path("/entity/")
+public final class Jaxb2ServiceTest {
+
+    @GET
+    @Produces(MediaType.APPLICATION_JSON)
+    @Path("/simple")
+    public final EntityTest simple() {
+        return new EntityTest("Hello", "World");
+    }
+
+    private static final class EntityTest {
+
+        private final String name;
+
+        private final String value;
+
+        EntityTest(final String name, final String value) {
+            this.name = name;
+            this.value = value;
+        }
+
+        @XmlElement(name = "jaxb")
+        @JsonGetter("name")
+        public final String getName() {
+            return name;
+        }
+
+        @JsonGetter("value")
+        public final Optional<String> getValue() {
+            return Optional.ofNullable(value);
+        }
+    }
+}
diff --git a/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/model/ServiceTest.java b/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/model/ServiceTest.java
index 23ac90d..314cc99 100644
--- a/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/model/ServiceTest.java
+++ b/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/model/ServiceTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2022 Oracle and/or its affiliates. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0, which is available at
diff --git a/pom.xml b/pom.xml
index 26aa611..e55a824 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1761,6 +1761,12 @@
             </dependency>
 
             <dependency>
+                <groupId>com.fasterxml.jackson.module</groupId>
+                <artifactId>jackson-module-jakarta-xmlbind-annotations</artifactId>
+                <version>${jackson.version}</version>
+            </dependency>
+
+            <dependency>
                 <groupId>xerces</groupId>
                 <artifactId>xercesImpl</artifactId>
                 <version>${xerces.version}</version>
diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/MultipartTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/MultipartTest.java
index 1c00186..682f1a8 100644
--- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/MultipartTest.java
+++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/MultipartTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2022 Oracle and/or its affiliates. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0, which is available at
@@ -31,6 +31,7 @@
 import jakarta.ws.rs.WebApplicationException;
 import jakarta.ws.rs.client.Entity;
 import jakarta.ws.rs.core.Application;
+import jakarta.ws.rs.core.Feature;
 import jakarta.ws.rs.core.HttpHeaders;
 import jakarta.ws.rs.core.MediaType;
 import jakarta.ws.rs.core.MultivaluedMap;
@@ -39,7 +40,7 @@
 import jakarta.ws.rs.ext.MessageBodyWriter;
 
 import org.glassfish.jersey.client.ClientConfig;
-//import org.glassfish.jersey.jackson.JacksonFeature;
+import org.glassfish.jersey.jackson.JacksonFeature;
 import org.glassfish.jersey.jsonb.JsonBindingFeature;
 import org.glassfish.jersey.media.multipart.FormDataBodyPart;
 import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
@@ -51,6 +52,9 @@
 import org.glassfish.jersey.test.JerseyTest;
 
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -58,8 +62,20 @@
 /**
  * @author Martin Matula
  */
+@RunWith(Parameterized.class)
 public class MultipartTest extends JerseyTest {
 
+    private static Class<? extends Feature> featureClass;
+
+    @Parameterized.Parameters(name = "Provider: {0}")
+    public static Iterable<Class[]> providers() {
+        return Arrays.asList(new Class[][]{{MoxyJsonFeature.class}, {JacksonFeature.class}, {JsonBindingFeature.class}});
+    }
+
+    public MultipartTest(Class<? extends Feature> featureProvider) {
+        super(configure(featureProvider));
+    }
+
     @SuppressWarnings("UnusedDeclaration")
     public static class MyObject {
 
@@ -156,19 +172,21 @@
         }
     }
 
-    @Override
-    protected Application configure() {
+    protected static Application configure(Class<? extends Feature> featureClass) {
+        MultipartTest.featureClass = featureClass;
         return new ResourceConfig(MultipartResource.class, MessageBodyProvider.class)
                 .register(MultiPartFeature.class)
+                .register(featureClass);
 //                .register(JacksonFeature.class);
-                .register(JsonBindingFeature.class);
+//                .register(JsonBindingFeature.class);
     }
 
     @Override
     protected void configureClient(final ClientConfig config) {
         config.register(MultiPartFeature.class);
+        config.register(featureClass);
         //config.register(JacksonFeature.class);
-        config.register(JsonBindingFeature.class);
+        //config.register(JsonBindingFeature.class);
     }
 
     @Test
@@ -207,6 +225,10 @@
      */
     @Test
     public void testSpecificListAsParameter() throws Exception {
+        if (featureClass == MoxyJsonFeature.class) {
+            // No available MessageBodyWriter for class "class java.util.Arrays$ArrayList" and media type "application/json"
+            return;
+        }
         final MyObject object = new MyObject("object");
         final List<MyObject> list = Arrays.asList(new MyObject("list1"), new MyObject("list2"));
 
diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/JsonTestProvider.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/JsonTestProvider.java
index 288a2e8..f15b9f7 100644
--- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/JsonTestProvider.java
+++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/JsonTestProvider.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2022 Oracle and/or its affiliates. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0, which is available at
@@ -30,7 +30,7 @@
 import jakarta.json.bind.JsonbBuilder;
 import jakarta.json.bind.JsonbConfig;
 
-//import org.glassfish.jersey.jackson.JacksonFeature;
+import org.glassfish.jersey.jackson.JacksonFeature;
 import org.glassfish.jersey.jettison.JettisonConfig;
 import org.glassfish.jersey.jettison.JettisonFeature;
 import org.glassfish.jersey.jsonb.JsonBindingFeature;
@@ -45,7 +45,7 @@
 public abstract class JsonTestProvider {
 
     public static final Collection<JsonTestProvider> JAXB_PROVIDERS = new LinkedHashSet<JsonTestProvider>() {{
-//        add(new JacksonJsonTestProvider());
+        add(new JacksonJsonTestProvider());
         add(new JettisonMappedJsonTestProvider());
         add(new JettisonBadgerfishJsonTestProvider());
         add(new MoxyJsonTestProvider());
@@ -54,7 +54,7 @@
 
     //  TODO add MoxyJsonTestProvider once MOXy supports POJO
     public static final Collection<JsonTestProvider> POJO_PROVIDERS = new LinkedHashSet<JsonTestProvider>() {{
-//        add(new JacksonJsonTestProvider());
+        add(new JacksonJsonTestProvider());
     }};
 
     private Feature feature;
@@ -125,7 +125,7 @@
             return JsonbBuilder.create(config);
         }
     }
-/*
+
     public static class JacksonJsonTestProvider extends JsonTestProvider {
 
         public JacksonJsonTestProvider() {
@@ -134,7 +134,7 @@
 
     }
 
-*/
+
 
     public static class JsonbTestProvider extends JsonTestProvider {
         public JsonbTestProvider() {
diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/JsonWithPaddingEncodingFilterTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/JsonWithPaddingEncodingFilterTest.java
index f334dd6..bc79f2c 100644
--- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/JsonWithPaddingEncodingFilterTest.java
+++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/JsonWithPaddingEncodingFilterTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2022 Oracle and/or its affiliates. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0, which is available at
@@ -24,7 +24,7 @@
 import jakarta.ws.rs.core.MultivaluedMap;
 import jakarta.ws.rs.core.Response;
 
-//import org.glassfish.jersey.jackson.JacksonFeature;
+import org.glassfish.jersey.jackson.JacksonFeature;
 import org.glassfish.jersey.message.DeflateEncoder;
 import org.glassfish.jersey.message.GZipEncoder;
 import org.glassfish.jersey.server.JSONP;
@@ -50,7 +50,7 @@
     protected ResourceConfig configure() {
         enable(TestProperties.LOG_TRAFFIC);
         return new ResourceConfig(MyResource.class)
-//                .register(JacksonFeature.class)
+                .register(JacksonFeature.class)
                 .register(EncodingFilter.class)
                 .register(GZipEncoder.class)
                 .register(DeflateEncoder.class);
diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/JsonWithPaddingTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/JsonWithPaddingTest.java
index 1a5d5e4..1a35164 100644
--- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/JsonWithPaddingTest.java
+++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/JsonWithPaddingTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2022 Oracle and/or its affiliates. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0, which is available at
@@ -30,7 +30,7 @@
 import jakarta.xml.bind.annotation.XmlRootElement;
 
 import org.glassfish.jersey.client.ClientConfig;
-// import org.glassfish.jersey.jackson.JacksonFeature;
+import org.glassfish.jersey.jackson.JacksonFeature;
 import org.glassfish.jersey.server.JSONP;
 import org.glassfish.jersey.server.ResourceConfig;
 import org.glassfish.jersey.test.JerseyTest;
@@ -176,9 +176,9 @@
         final Response response = target("jsonp").path("PureJson").request("application/x-javascript").get();
 
         // Method is invoked but we do not have a MBW for application/x-javascript.
-        /* if (jsonTestProvider.getFeature().getClass() == JacksonFeature.class) {
+        if (jsonTestProvider.getFeature().getClass() == JacksonFeature.class) {
             assertThat(response.getStatus(), equalTo(200));
-        } else */ {
+        } else  {
             assertThat(response.getStatus(), equalTo(500));
         }
     }
diff --git a/tests/osgi/functional/pom.xml b/tests/osgi/functional/pom.xml
index 69dd5bd..e024b15 100644
--- a/tests/osgi/functional/pom.xml
+++ b/tests/osgi/functional/pom.xml
@@ -46,11 +46,6 @@
                         <goals>
                             <goal>testCompile</goal>
                         </goals>
-                        <configuration>
-                            <testExcludes>
-                                <exclude>org/glassfish/jersey/osgi/test/basic/JsonJacksonTest.java</exclude>
-                            </testExcludes>
-                        </configuration>
                     </execution>
                 </executions>
             </plugin>
@@ -347,7 +342,7 @@
         </dependency>
         <dependency>
             <groupId>com.fasterxml.jackson.module</groupId>
-            <artifactId>jackson-module-jaxb-annotations</artifactId>
+            <artifactId>jackson-module-jakarta-xmlbind-annotations</artifactId>
             <scope>test</scope>
         </dependency>
         <dependency>
@@ -356,17 +351,6 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>com.fasterxml.jackson.jaxrs</groupId>
-            <artifactId>jackson-jaxrs-base</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>com.fasterxml.jackson.jaxrs</groupId>
-            <artifactId>jackson-jaxrs-json-provider</artifactId>
-            <scope>test</scope>
-        </dependency>
-
-        <dependency>
             <groupId>com.sun.xml.bind</groupId>
             <artifactId>jaxb-osgi</artifactId>
             <scope>test</scope>
diff --git a/tests/osgi/functional/src/test/java/org/glassfish/jersey/osgi/test/basic/JsonJacksonTest.java b/tests/osgi/functional/src/test/java/org/glassfish/jersey/osgi/test/basic/JsonJacksonTest.java
index a719d5f..7d06f02 100644
--- a/tests/osgi/functional/src/test/java/org/glassfish/jersey/osgi/test/basic/JsonJacksonTest.java
+++ b/tests/osgi/functional/src/test/java/org/glassfish/jersey/osgi/test/basic/JsonJacksonTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2022 Oracle and/or its affiliates. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0, which is available at
@@ -48,10 +48,7 @@
                 mavenBundle().groupId("com.fasterxml.jackson.core").artifactId("jackson-core").versionAsInProject(),
                 mavenBundle().groupId("com.fasterxml.jackson.core").artifactId("jackson-databind").versionAsInProject(),
                 mavenBundle().groupId("com.fasterxml.jackson.core").artifactId("jackson-annotations").versionAsInProject(),
-                mavenBundle().groupId("com.fasterxml.jackson.jaxrs").artifactId("jackson-jaxrs-base").versionAsInProject(),
-                mavenBundle().groupId("com.fasterxml.jackson.jaxrs").artifactId("jackson-jaxrs-json-provider")
-                        .versionAsInProject(),
-                mavenBundle().groupId("com.fasterxml.jackson.module").artifactId("jackson-module-jaxb-annotations")
+                mavenBundle().groupId("com.fasterxml.jackson.module").artifactId("jackson-module-jakarta-xmlbind-annotations")
                         .versionAsInProject()
         ));