Make JacksonFeature configurable (#5074)

Signed-off-by: Maxim Nesen <maxim.nesen@oracle.com>
diff --git a/core-common/src/main/java/org/glassfish/jersey/CommonProperties.java b/core-common/src/main/java/org/glassfish/jersey/CommonProperties.java
index 50fceb1..762a08b 100644
--- a/core-common/src/main/java/org/glassfish/jersey/CommonProperties.java
+++ b/core-common/src/main/java/org/glassfish/jersey/CommonProperties.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2021 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
@@ -256,6 +256,55 @@
     public static final String JAXRS_SERVICE_LOADING_ENABLE = "jakarta.ws.rs.loadServices";
 
     /**
+     * Comma separated list of jackson modules which are only enabled (only those modules will be used)
+     * for json-jackson processing
+     *
+     * @since 2.36
+     */
+    public static final String JSON_JACKSON_ENABLED_MODULES = "jersey.config.json.jackson.enabled.modules";
+
+    /**
+     * Client-specific version of {@link CommonProperties#JSON_JACKSON_ENABLED_MODULES}.
+     *
+     * If present, it overrides the generic one for the client environment.
+     * @since 2.36
+     */
+    public static final String JSON_JACKSON_ENABLED_MODULES_CLIENT = "jersey.config.client.json.jackson.enabled.modules";
+
+    /**
+     * Server-specific version of {@link CommonProperties#JSON_JACKSON_ENABLED_MODULES}.
+     *
+     * If present, it overrides the generic one for the server environment.
+     * @since 2.36
+     */
+    public static final String JSON_JACKSON_ENABLED_MODULES_SERVER = "jersey.config.server.json.jackson.enabled.modules";
+
+    /**
+     * Comma separated list of jackson modules which shall be excluded from json-jackson processing.
+     * the JaxbAnnotationModule is always excluded (cannot be configured).
+     *
+     * @since 2.36
+     */
+
+    public static final String JSON_JACKSON_DISABLED_MODULES = "jersey.config.json.jackson.disabled.modules";
+
+    /**
+     * Client-specific version of {@link CommonProperties#JSON_JACKSON_DISABLED_MODULES}.
+     *
+     * If present, it overrides the generic one for the client environment.
+     * @since 2.36
+     */
+    public static final String JSON_JACKSON_DISABLED_MODULES_CLIENT = "jersey.config.client.json.jackson.disabled.modules";
+
+    /**
+     * Server-specific version of {@link CommonProperties#JSON_JACKSON_DISABLED_MODULES}.
+     *
+     * If present, it overrides the generic one for the client environment.
+     * @since 2.36
+     */
+    public static final String JSON_JACKSON_DISABLED_MODULES_SERVER = "jersey.config.server.json.jackson.disabled.modules";
+
+    /**
      * Prevent instantiation.
      */
     private CommonProperties() {
@@ -274,7 +323,7 @@
      *
      * @since 2.8
      */
-    public static Object getValue(final Map<String, ?> properties, final String propertyName, final Class<?> type) {
+    public static <T> T getValue(final Map<String, ?> properties, final String propertyName, final Class<T> type) {
         return PropertiesHelper.getValue(properties, propertyName, type, CommonProperties.LEGACY_FALLBACK_MAP);
     }
 
diff --git a/docs/src/main/docbook/appendix-properties.xml b/docs/src/main/docbook/appendix-properties.xml
index 0f085eb..3da415b 100644
--- a/docs/src/main/docbook/appendix-properties.xml
+++ b/docs/src/main/docbook/appendix-properties.xml
@@ -148,6 +148,42 @@
                         </entry>
                     </row>
                     <row>
+                        <entry>&jersey.common.CommonProperties.JSON_JACKSON_ENABLED_MODULES; /
+                        <entry>&jersey.common.CommonProperties.JSON_JACKSON_ENABLED_MODULES_CLIENT; /
+                        <entry>&jersey.common.CommonProperties.JSON_JACKSON_ENABLED_MODULES_SERVER;
+                        </entry>
+                        <entry>
+                            <literal>jersey.config.json.jackson.enabled.modules</literal>
+                            <literal>jersey.config.client.json.jackson.enabled.modules</literal>
+                            <literal>jersey.config.server.json.jackson.enabled.modules</literal>
+                        </entry>
+                        <entry>
+                            Comma separated list of jackson modules which shall be used for json-jackson provider.
+                            If set, only those modules will be used for JSON processing.
+
+                            Default value is <literal>NULL</literal>
+                            @since 2.36
+                        </entry>
+                    </row>
+                    <row>
+                        <entry>&jersey.common.CommonProperties.JSON_JACKSON_DISABLED_MODULES; /
+                        <entry>&jersey.common.CommonProperties.JSON_JACKSON_DISABLED_MODULES_CLIENT; /
+                        <entry>&jersey.common.CommonProperties.JSON_JACKSON_DISABLED_MODULES_SERVER;
+                        </entry>
+                        <entry>
+                            <literal>jersey.config.json.jackson.disabled.modules</literal>
+                            <literal>jersey.config.client.json.jackson.disabled.modules</literal>
+                            <literal>jersey.config.server.json.jackson.disabled.modules</literal>
+                        </entry>
+                        <entry>
+                            Comma separated list of jackson modules which shall be excluded from json-jackson provider.
+                            If set, those modules will be excluded from JSON processing.
+
+                            Default value is <literal>NULL</literal>
+                            @since 2.36
+                        </entry>
+                    </row>
+                    <row>
                         <entry>&jersey.logging.LoggingFeature.LOGGING_FEATURE_LOGGER_NAME;
                         </entry>
                         <entry>
diff --git a/docs/src/main/docbook/jersey.ent b/docs/src/main/docbook/jersey.ent
index 1c8bdb0..e463997 100644
--- a/docs/src/main/docbook/jersey.ent
+++ b/docs/src/main/docbook/jersey.ent
@@ -394,6 +394,12 @@
 <!ENTITY jersey.common.CommonProperties.OUTBOUND_CONTENT_LENGTH_BUFFER_CLIENT "<link xlink:href='&jersey.javadoc.uri.prefix;/CommonProperties.html#OUTBOUND_CONTENT_LENGTH_BUFFER_CLIENT'>CommonProperties.OUTBOUND_CONTENT_LENGTH_BUFFER_CLIENT</link>" >
 <!ENTITY jersey.common.CommonProperties.OUTBOUND_CONTENT_LENGTH_BUFFER_SERVER "<link xlink:href='&jersey.javadoc.uri.prefix;/CommonProperties.html#OUTBOUND_CONTENT_LENGTH_BUFFER_SERVER'>CommonProperties.OUTBOUND_CONTENT_LENGTH_BUFFER_SERVER</link>" >
 <!ENTITY jersey.common.CommonProperties.PROVIDER_DEFAULT_DISABLE "<link xlink:href='&jersey.javadoc.uri.prefix;/CommonProperties.html#PROVIDER_DEFAULT_DISABLE'>CommonProperties.PROVIDER_DEFAULT_DISABLE</link>" >
+<!ENTITY jersey.common.CommonProperties.JSON_JACKSON_ENABLED_MODULES "<link xlink:href='&jersey.javadoc.uri.prefix;/CommonProperties.html#JSON_JACKSON_ENABLED_MODULES'>CommonProperties.JSON_JACKSON_ENABLED_MODULES</link>" >
+<!ENTITY jersey.common.CommonProperties.JSON_JACKSON_ENABLED_MODULES_CLIENT "<link xlink:href='&jersey.javadoc.uri.prefix;/CommonProperties.html#JSON_JACKSON_ENABLED_MODULES'>CommonProperties.JSON_JACKSON_ENABLED_MODULES_CLIENT</link>" >
+<!ENTITY jersey.common.CommonProperties.JSON_JACKSON_ENABLED_MODULES_SERVER "<link xlink:href='&jersey.javadoc.uri.prefix;/CommonProperties.html#JSON_JACKSON_ENABLED_MODULES'>CommonProperties.JSON_JACKSON_ENABLED_MODULES_SERVER</link>" >
+<!ENTITY jersey.common.CommonProperties.JSON_JACKSON_DISABLED_MODULES "<link xlink:href='&jersey.javadoc.uri.prefix;/CommonProperties.html#JSON_JACKSON_DISABLED_MODULES'>CommonProperties.JSON_JACKSON_DISABLED_MODULES</link>" >
+<!ENTITY jersey.common.CommonProperties.JSON_JACKSON_DISABLED_MODULES_CLIENT "<link xlink:href='&jersey.javadoc.uri.prefix;/CommonProperties.html#JSON_JACKSON_DISABLED_MODULES'>CommonProperties.JSON_JACKSON_DISABLED_MODULES_CLIENT</link>" >
+<!ENTITY jersey.common.CommonProperties.JSON_JACKSON_DISABLED_MODULES_SERVER "<link xlink:href='&jersey.javadoc.uri.prefix;/CommonProperties.html#JSON_JACKSON_DISABLED_MODULES'>CommonProperties.JSON_JACKSON_DISABLED_MODULES_SERVER</link>" >
 <!ENTITY jersey.common.internal.inject.DisposableSupplier "<link xlink:href='&jersey.javadoc.uri.prefix;/internal/inject/DisposableSupplier.html'>DisposableSupplier</link>">
 <!ENTITY jersey.common.internal.inject.InjectionManager "<link xlink:href='&jersey.javadoc.uri.prefix;/internal/inject/InjectionManager.html'>InjectionManager</link>">
 <!ENTITY jersey.common.internal.inject.AbstractBinder "<link xlink:href='&jersey.javadoc.uri.prefix;/internal/inject/AbstractBinder.html'>AbstractBinder</link>">
diff --git a/docs/src/main/docbook/media.xml b/docs/src/main/docbook/media.xml
index 547ac61..2946993 100644
--- a/docs/src/main/docbook/media.xml
+++ b/docs/src/main/docbook/media.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" standalone="no"?>
 <!--
 
-    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
@@ -580,6 +580,15 @@
                 </para>
 
                 <para>
+                    Since the 2.36 version of Jersey it is possible to filter (include/exclude) Jackson modules by properties
+                    &jersey.common.CommonProperties.JSON_JACKSON_DISABLED_MODULES; and &jersey.common.CommonProperties.JSON_JACKSON_ENABLED_MODULES;
+                    (with their client/server derivatives). If the &jersey.common.CommonProperties.JSON_JACKSON_ENABLED_MODULES; property is used,
+                    only those named modules will be used for JSON processing. On the other hand if the &jersey.common.CommonProperties.JSON_JACKSON_DISABLED_MODULES;
+                    property is used, those listed modules will be explicitly excluded from processing while other (not listed) will remain. Please note that
+                    the <literal>JaxbAnnotationModule</literal> module is always excluded from processing and this is not configurable.
+                </para>
+
+                <para>
                     In order to use Jackson as your JSON (JAXB/POJO) provider you need to register &jersey.media.JacksonFeature;
                     (&jersey.media.Jackson1Feature;) and a &lit.jaxrs.ext.ContextResolver; for &lit.jersey.media.ObjectMapper;,
                     if needed, in your &jaxrs.core.Configurable; (client/server).
diff --git a/media/json-jackson/pom.xml b/media/json-jackson/pom.xml
index bacc44e..a70f3ed 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
@@ -122,7 +122,6 @@
             <groupId>com.fasterxml.jackson.module</groupId>
             <artifactId>jackson-module-jaxb-annotations</artifactId>
         </dependency>
-
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
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 8219cb1..a75544c 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
@@ -18,11 +18,16 @@
 
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.Module;
+import org.glassfish.jersey.CommonProperties;
 import org.glassfish.jersey.jackson.internal.jackson.jaxrs.cfg.Annotations;
 import org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJaxbJsonProvider;
 
+import java.util.Arrays;
 import java.util.List;
+import javax.annotation.PostConstruct;
 import javax.inject.Singleton;
+import javax.ws.rs.core.Configuration;
+import javax.ws.rs.core.Context;
 
 /**
  * Entity Data provider based on Jackson JSON provider.
@@ -30,30 +35,55 @@
 @Singleton
 public class DefaultJacksonJaxbJsonProvider extends JacksonJaxbJsonProvider {
 
+    @Context
+    private Configuration commonConfig;
+
     //do not register JaxbAnnotationModule because it brakes default annotations processing
     private static final String EXCLUDE_MODULE_NAME = "JaxbAnnotationModule";
 
     public DefaultJacksonJaxbJsonProvider() {
         super();
-        findAndRegisterModules();
     }
 
     public DefaultJacksonJaxbJsonProvider(final Annotations... annotationsToUse) {
         super(annotationsToUse);
-        findAndRegisterModules();
     }
 
+    @PostConstruct
     private void findAndRegisterModules() {
 
         final ObjectMapper defaultMapper = _mapperConfig.getDefaultMapper();
         final ObjectMapper mapper = _mapperConfig.getConfiguredMapper();
 
-        final List<Module> modules = ObjectMapper.findModules();
-        modules.removeIf(mod -> mod.getModuleName().contains(EXCLUDE_MODULE_NAME));
+        final List<Module> modules = filterModules();
 
         defaultMapper.registerModules(modules);
         if (mapper != null) {
             mapper.registerModules(modules);
         }
     }
+
+    private List<Module> filterModules() {
+        final String disabledModules =
+                CommonProperties.getValue(commonConfig.getProperties(),
+                        commonConfig.getRuntimeType(),
+                        CommonProperties.JSON_JACKSON_DISABLED_MODULES, String.class);
+        final String enabledModules =
+                CommonProperties.getValue(commonConfig.getProperties(),
+                        commonConfig.getRuntimeType(),
+                        CommonProperties.JSON_JACKSON_ENABLED_MODULES, String.class);
+
+        final List<Module> modules = ObjectMapper.findModules();
+        modules.removeIf(mod -> mod.getModuleName().contains(EXCLUDE_MODULE_NAME));
+
+        if (enabledModules != null && !enabledModules.isEmpty()) {
+            final List<String> enabledModulesList = Arrays.asList(enabledModules.split(","));
+            modules.removeIf(mod -> !enabledModulesList.contains(mod.getModuleName()));
+        } else if (disabledModules != null && !disabledModules.isEmpty()) {
+            final List<String> disabledModulesList = Arrays.asList(disabledModules.split(","));
+            modules.removeIf(mod -> disabledModulesList.contains(mod.getModuleName()));
+        }
+
+        return modules;
+    }
 }
\ No newline at end of file
diff --git a/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/DefaultJsonJacksonProviderForBothModulesTest.java b/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/DefaultJsonJacksonProviderForBothModulesTest.java
new file mode 100644
index 0000000..d8d43c0
--- /dev/null
+++ b/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/DefaultJsonJacksonProviderForBothModulesTest.java
@@ -0,0 +1,43 @@
+/*
+ * 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 org.glassfish.jersey.jackson.internal.model.ServiceTest;
+import org.glassfish.jersey.server.ResourceConfig;
+import org.glassfish.jersey.test.JerseyTest;
+import org.junit.Test;
+
+import javax.ws.rs.core.Application;
+
+import static org.junit.Assert.assertEquals;
+
+public class DefaultJsonJacksonProviderForBothModulesTest extends JerseyTest {
+    @Override
+    protected final Application configure() {
+        return new ResourceConfig(ServiceTest.class)
+                .property("jersey.config.json.jackson.enabled.modules", "Jdk8Module");
+    }
+
+    @Test
+    public final void testDisabledModule() {
+        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/DefaultJsonJacksonProviderForDisabledModulesTest.java b/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/DefaultJsonJacksonProviderForDisabledModulesTest.java
new file mode 100644
index 0000000..3a1bbe6
--- /dev/null
+++ b/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/DefaultJsonJacksonProviderForDisabledModulesTest.java
@@ -0,0 +1,71 @@
+/*
+ * 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 org.glassfish.jersey.CommonProperties;
+import org.glassfish.jersey.jackson.JacksonFeature;
+import org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJaxbJsonProvider;
+import org.glassfish.jersey.jackson.internal.model.JAXBServiceTest;
+import org.glassfish.jersey.jackson.internal.model.ServiceTest;
+import org.glassfish.jersey.server.ResourceConfig;
+import org.glassfish.jersey.test.JerseyTest;
+import org.junit.Test;
+
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+import javax.ws.rs.core.Application;
+import javax.ws.rs.core.Configuration;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+
+public class DefaultJsonJacksonProviderForDisabledModulesTest extends JerseyTest {
+    @Override
+    protected final Application configure() {
+        return new ResourceConfig(ServiceTest.class, JAXBServiceTest.class)
+                .property("jersey.config.json.jackson.disabled.modules", "Jdk8Module");
+    }
+
+    @Test
+    public final void testDisabledModule() {
+        getClient()
+                .register(JacksonFeature.class)
+                .register(TestJacksonJaxbJsonProvider.class)
+                .property("jersey.config.json.jackson.disabled.modules", "Jdk8Module");
+        final String response = target("JAXBEntity")
+                .request().get(String.class);
+        assertNotEquals("{\"key\":\"key\",\"value\":\"value\"}", response);
+    }
+
+    private static class TestJacksonJaxbJsonProvider extends JacksonJaxbJsonProvider {
+
+        @Inject
+        private Configuration configuration;
+
+        @PostConstruct
+        public void checkModulesCount() {
+            final String disabledModules =
+                    CommonProperties.getValue(configuration.getProperties(),
+                            configuration.getRuntimeType(),
+                            CommonProperties.JSON_JACKSON_DISABLED_MODULES, String.class);
+            assertEquals("Jdk8Module", disabledModules);
+        }
+
+    }
+
+}
\ No newline at end of file
diff --git a/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/DefaultJsonJacksonProviderForEnabledModulesTest.java b/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/DefaultJsonJacksonProviderForEnabledModulesTest.java
new file mode 100644
index 0000000..76b7dd9
--- /dev/null
+++ b/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/DefaultJsonJacksonProviderForEnabledModulesTest.java
@@ -0,0 +1,42 @@
+/*
+ * 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 org.glassfish.jersey.jackson.internal.model.ServiceTest;
+import org.glassfish.jersey.server.ResourceConfig;
+import org.glassfish.jersey.test.JerseyTest;
+import org.junit.Test;
+
+import javax.ws.rs.core.Application;
+
+import static org.junit.Assert.assertNotEquals;
+
+public class DefaultJsonJacksonProviderForEnabledModulesTest extends JerseyTest {
+    @Override
+    protected final Application configure() {
+        return new ResourceConfig(ServiceTest.class)
+                .property("jersey.config.json.jackson.enabled.modules", "jackson-module-kotlin");
+    }
+
+    @Test
+    public final void testDisabledModule() {
+        final String response = target("entity/simple")
+                .request().get(String.class);
+        assertNotEquals("{\"name\":\"Hello\",\"value\":\"World\"}", response);
+    }
+
+}
diff --git a/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/model/JAXBServiceTest.java b/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/model/JAXBServiceTest.java
new file mode 100644
index 0000000..80dbef0
--- /dev/null
+++ b/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/model/JAXBServiceTest.java
@@ -0,0 +1,62 @@
+/*
+ * 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.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.util.Optional;
+
+@Path("JAXBEntity")
+public class JAXBServiceTest {
+    @GET
+    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+    public SimpleEntity get() {
+        return new SimpleEntity("key", "value");
+    }
+
+    @XmlRootElement
+    public static class SimpleEntity {
+        @JsonProperty
+        private String key;
+
+        @JsonProperty
+        private String value;
+
+        public SimpleEntity() {
+            key = "key";
+            value = "value";
+        }
+        public SimpleEntity(String key, String value) {
+            this.key = key;
+            this.value = value;
+        }
+
+        public Optional<String> getKey() {
+            return Optional.ofNullable(key);
+        }
+
+        public Optional<String> getValue() {
+            return Optional.ofNullable(value);
+        }
+
+    }
+}
diff --git a/tests/integration/microprofile/rest-client14-compatibility/pom.xml b/tests/integration/microprofile/rest-client14-compatibility/pom.xml
index 7c7733a..4af7543 100644
--- a/tests/integration/microprofile/rest-client14-compatibility/pom.xml
+++ b/tests/integration/microprofile/rest-client14-compatibility/pom.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 
-    Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved.
+    Copyright (c) 2021, 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
@@ -106,10 +106,5 @@
             <type>pom</type>
             <scope>test</scope>
         </dependency>
-        <dependency>
-            <groupId>org.glassfish.jersey.ext.cdi</groupId>
-            <artifactId>jersey-weld2-se</artifactId>
-            <scope>test</scope>
-        </dependency>
     </dependencies>
 </project>