Native image fixes for new Jersey version. (#1910)

* Native image fixes for new Jersey version.
* Jersey client now works without additional dependencies.
* Fix for modularized runtime.

Signed-off-by: Tomas Langer <tomas.langer@oracle.com>
This commit is contained in:
Tomas Langer
2020-06-01 17:05:04 +02:00
committed by GitHub
parent a80c90069e
commit 4fd2129a7f
14 changed files with 73 additions and 69 deletions

19
dependencies/pom.xml vendored
View File

@@ -128,6 +128,21 @@
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>${version.lib.jersey}</version>
<exclusions>
<exclusion>
<groupId>org.glassfish.hk2.external</groupId>
<artifactId>jakarta.inject</artifactId>
</exclusion>
<exclusion>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-jaxb</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>${version.lib.jersey}</version>
<exclusions>
<exclusion>
<groupId>org.glassfish.hk2.external</groupId>
@@ -950,6 +965,10 @@
<groupId>jakarta.json</groupId>
<artifactId>jakarta.json-api</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.activation</groupId>
<artifactId>jakarta.activation</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>

View File

@@ -31,9 +31,6 @@ module io.helidon.security.examples.abac {
requires io.helidon.security.abac.policy;
requires io.helidon.security.abac.scope;
// needed for jersey to start without a lot of errors (hk2 actually)
requires java.xml.bind;
// java util logging
requires java.logging;

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2017, 2020 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2017, 2020 Oracle and/or its affiliates.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -66,13 +66,8 @@
<artifactId>helidon-config-yaml</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<groupId>io.helidon.jersey</groupId>
<artifactId>helidon-jersey-client</artifactId>
<scope>test</scope>
</dependency>
<dependency>

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2019, 2020 Oracle and/or its affiliates.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -36,27 +36,19 @@
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>${version.lib.jersey}</version>
<exclusions>
<exclusion>
<groupId>org.glassfish.hk2.external</groupId>
<artifactId>jakarta.inject</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
</dependency>
<dependency>
<!-- this module is required by Jakarta JAX-RS (requires transitive in module-info.java) -->
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<exclusions>
<exclusion>
<groupId>jakarta.activation</groupId>
<artifactId>jakarta.activation-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>jakarta.inject</groupId>
<artifactId>jakarta.inject-api</artifactId>
</dependency>
</dependencies>

View File

@@ -21,6 +21,4 @@ module io.helidon.jersey.client {
requires transitive java.ws.rs;
requires transitive jersey.common;
requires transitive jersey.client;
requires java.xml.bind;
}

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2019, 2020 Oracle and/or its affiliates.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -37,30 +37,21 @@
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>${version.lib.jersey}</version>
<exclusions>
<exclusion>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-jaxb</artifactId>
</exclusion>
<exclusion>
<groupId>org.glassfish.hk2.external</groupId>
<artifactId>jakarta.inject</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
</dependency>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
</dependency>
<dependency>
<!-- needed for proper module name in module-info.java -->
<groupId>jakarta.inject</groupId>
<artifactId>jakarta.inject-api</artifactId>
</dependency>
<dependency>
<!-- this module is required by Jakarta JAX-RS (requires transitive in module-info.java) -->
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
</dependency>
</dependencies>
<profiles>

View File

@@ -25,6 +25,4 @@ module io.helidon.jersey.server {
requires transitive jakarta.inject.api;
requires transitive jakarta.activation;
requires transitive java.annotation;
requires transitive java.xml.bind;
}

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2019, 2020 Oracle and/or its affiliates.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -34,6 +34,7 @@
<dependency>
<groupId>io.helidon.microprofile.server</groupId>
<artifactId>helidon-microprofile-server</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.helidon.webserver</groupId>

View File

@@ -53,16 +53,6 @@
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-binding</artifactId>
<exclusions>
<exclusion>
<groupId>jakarta.activation</groupId>
<artifactId>jakarta.activation-api</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.activation</groupId>
<artifactId>jakarta.activation</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.helidon.tests.apps.bookstore.common</groupId>

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2018, 2020 Oracle and/or its affiliates.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -63,18 +63,8 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jakarta.activation</groupId>
<artifactId>jakarta.activation-api</artifactId>
<groupId>io.helidon.jersey</groupId>
<artifactId>helidon-jersey-client</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2019, 2020 Oracle and/or its affiliates.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -36,6 +36,7 @@
<dependency>
<groupId>io.helidon.webserver</groupId>
<artifactId>helidon-webserver</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>

View File

@@ -28,6 +28,7 @@ import java.util.Map;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import java.util.logging.Logger;
@@ -435,6 +436,9 @@ public class JerseySupport implements Service {
* Builder for convenient way to create {@link JerseySupport}.
*/
public static final class Builder implements Configurable<Builder>, io.helidon.common.Builder<JerseySupport> {
private static final String JERSEY_DISABLE_PROVIDERS = "jersey.config.disableDefaultProvider";
private static final String JERSEY_DISABLE_WADL = "jersey.config.server.wadl.disableWadl";
private static final AtomicBoolean SYS_PROP_HANDLED = new AtomicBoolean();
private ResourceConfig resourceConfig;
private ExecutorService executorService;
@@ -446,6 +450,25 @@ public class JerseySupport implements Service {
}
private Builder(Application application) {
if (SYS_PROP_HANDLED.compareAndSet(false, true)) {
String property = System.getProperty(JERSEY_DISABLE_PROVIDERS);
if (null == property) {
LOGGER.fine("Disabling all Jersey default providers (DOM, SAX, Rendered Image, XML Source, and "
+ "XML Stream Source). You can enabled them by setting system property "
+ JERSEY_DISABLE_PROVIDERS + " to NONE");
System.setProperty(JERSEY_DISABLE_PROVIDERS, "ALL");
} else if ("NONE".equals(property)) {
System.getProperties().remove(JERSEY_DISABLE_PROVIDERS);
}
property = System.getProperty(JERSEY_DISABLE_WADL);
if (null == property) {
LOGGER.fine("Disabling Jersey WADL feature, you can enable it by setting system property "
+ JERSEY_DISABLE_WADL + " to false");
System.setProperty(JERSEY_DISABLE_WADL, "true");
}
}
if (application == null) {
application = new Application();
}

View File

@@ -30,5 +30,9 @@
[
"javax.ws.rs.container.ResourceContext",
"org.glassfish.hk2.api.ProxyCtl"
],
[
"org.glassfish.jersey.server.ExtendedUriInfo",
"org.glassfish.hk2.api.ProxyCtl"
]
]

View File

@@ -1,4 +1,9 @@
{
"bundles": [
{
"name": "javax.xml.bind.Messages"
}
],
"resources": [
{
"pattern": "org/glassfish/jersey/internal/build.properties"