From 44f09de33adc21e206c08807a02ef13758b2bcfb Mon Sep 17 00:00:00 2001 From: Foivos Zakkak Date: Tue, 17 Dec 2024 11:13:17 +0200 Subject: [PATCH] Improve documentation for handling proxies in native-mode Follow up to https://github.com/quarkusio/quarkus/pull/45004 (cherry picked from commit 036cc7fc1c1bc18222ded80865e8ea886d100aa6) --- .../writing-native-applications-tips.adoc | 33 ++++++++++++------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/docs/src/main/asciidoc/writing-native-applications-tips.adoc b/docs/src/main/asciidoc/writing-native-applications-tips.adoc index e4e19d35f0d73..32a6917cc22e0 100644 --- a/docs/src/main/asciidoc/writing-native-applications-tips.adoc +++ b/docs/src/main/asciidoc/writing-native-applications-tips.adoc @@ -320,6 +320,23 @@ and in the case of using the Maven configuration instead of `application.propert ---- ==== +[[managing-proxy-classes-app]] +=== Managing Proxy Classes + +While writing native application you'll need to define proxy classes at image build time by specifying the list of interfaces that they implement. + +In such a situation, the error you might encounter is: + +[source] +---- +com.oracle.svm.core.jdk.UnsupportedFeatureError: Proxy class defined by interfaces [interface org.apache.http.conn.HttpClientConnectionManager, interface org.apache.http.pool.ConnPoolControl, interface com.amazonaws.http.conn.Wrapped] not found. Generating proxy classes at runtime is not supported. Proxy classes need to be defined at image build time by specifying the list of interfaces that they implement. To define proxy classes use -H:DynamicProxyConfigurationFiles= and -H:DynamicProxyConfigurationResources= options. +---- + +To solve the issue you can create a `proxy-config.json` file under the `src/main/resources/META-INF/native-image//` folder. +For more information about the format of the `proxy-config.json`, see the https://www.graalvm.org/{graalvm-docs-version}/reference-manual/native-image/metadata/#dynamic-proxy-metadata-in-json[Dynamic Proxy Metadata in JSON] documentation. + +Alternatively, you can create a quarkus extension and register the proxy classes as described in <>. + [[modularity-benefits]] === Modularity Benefits @@ -618,18 +635,10 @@ Using such a construct means that a `--initialize-at-run-time` option will autom For more information about the `--initialize-at-run-time` option, see the link:https://www.graalvm.org/{graalvm-docs-version}/reference-manual/native-image/optimizations-and-performance/ClassInitialization/[GraalVM Class Initialization in Native Image] guide. ==== +[[managing-proxy-classes-extension]] === Managing Proxy Classes -While writing native application you'll need to define proxy classes at image build time by specifying the list of interfaces that they implement. - -In such a situation, the error you might encounter is: - -[source] ----- -com.oracle.svm.core.jdk.UnsupportedFeatureError: Proxy class defined by interfaces [interface org.apache.http.conn.HttpClientConnectionManager, interface org.apache.http.pool.ConnPoolControl, interface com.amazonaws.http.conn.Wrapped] not found. Generating proxy classes at runtime is not supported. Proxy classes need to be defined at image build time by specifying the list of interfaces that they implement. To define proxy classes use -H:DynamicProxyConfigurationFiles= and -H:DynamicProxyConfigurationResources= options. ----- - -Quarkus allows extensions authors to register a `NativeImageProxyDefinitionBuildItem`. An example of doing so is: +Similarly, Quarkus allows extensions authors to register a `NativeImageProxyDefinitionBuildItem`. An example of doing so is: [source,java] ---- @@ -645,8 +654,8 @@ public class S3Processor { ---- This will allow Quarkus to generate the necessary configuration for handling the proxy class. -Alternatively, you may create a `proxy-config.json` file under the `src/main/resources/META-INF/native-image//` folder. -For more information about the format of this file, see the https://www.graalvm.org/{graalvm-docs-version}/reference-manual/native-image/metadata/#dynamic-proxy-metadata-in-json[Dynamic Proxy Metadata in JSON] documentation. + +Alternatively, you may create a `proxy-config.json` as described in <>. [NOTE] ====