You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expected behavior
The native image should be generated
Actual behavior
Native image generation error:
Error: No instances of sun.security.provider.NativePRNG are allowed in the image heap as this class should be initialized at image runtime. To see how this object got instantiated use -H:+TraceClassInitialization.
Detailed message:
Trace: object java.security.SecureRandom
object sun.security.ssl.SSLContextImpl$TLSContext
object sun.security.ssl.SSLSocketFactoryImpl
object org.apache.http.conn.ssl.SSLConnectionSocketFactory
object java.util.concurrent.ConcurrentHashMap$Node
object java.util.concurrent.ConcurrentHashMap$Node[]
object java.util.concurrent.ConcurrentHashMap
object org.apache.http.config.Registry
object org.apache.http.impl.conn.DefaultHttpClientConnectionOperator
object org.apache.http.impl.conn.PoolingHttpClientConnectionManager
object org.apache.http.impl.client.HttpClientBuilder$2
object java.lang.Object[]
object java.util.ArrayList
object org.apache.http.impl.client.InternalHttpClient
object org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient43Engine
object org.jboss.resteasy.client.jaxrs.internal.ResteasyClientImpl
object org.codependent.RestClient_ClientProxy
object org.codependent.RestClient_Bean
object java.lang.Object[]
object java.util.ArrayList
object io.quarkus.arc.impl.ArcContainerImpl
object io.quarkus.arc.runtime.ArcRecorder$2
field io.quarkus.resteasy.common.runtime.QuarkusInjectorFactory.CONTAINER
com.oracle.svm.core.util.UserError$UserException: No instances of sun.security.provider.NativePRNG are allowed in the image heap as this class should be initialized at image runtime. To see how this object got instantiated use -H:+TraceClassInitialization.
Detailed message:
Trace: object java.security.SecureRandom
object sun.security.ssl.SSLContextImpl$TLSContext
object sun.security.ssl.SSLSocketFactoryImpl
object org.apache.http.conn.ssl.SSLConnectionSocketFactory
object java.util.concurrent.ConcurrentHashMap$Node
object java.util.concurrent.ConcurrentHashMap$Node[]
object java.util.concurrent.ConcurrentHashMap
object org.apache.http.config.Registry
object org.apache.http.impl.conn.DefaultHttpClientConnectionOperator
object org.apache.http.impl.conn.PoolingHttpClientConnectionManager
object org.apache.http.impl.client.HttpClientBuilder$2
object java.lang.Object[]
object java.util.ArrayList
object org.apache.http.impl.client.InternalHttpClient
object org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient43Engine
object org.jboss.resteasy.client.jaxrs.internal.ResteasyClientImpl
object org.codependent.RestClient_ClientProxy
object org.codependent.RestClient_Bean
object java.lang.Object[]
object java.util.ArrayList
object io.quarkus.arc.impl.ArcContainerImpl
object io.quarkus.arc.runtime.ArcRecorder$2
field io.quarkus.resteasy.common.runtime.QuarkusInjectorFactory.CONTAINER
Configuration
Screenshots
Environment (please complete the following information):
Output of uname -a or ver: 19.3.0 Darwin Kernel
Output of java -version: 11.0.6 AdoptOpenJDK
GraalVM version (if different from Java):
Quarkus version or git rev: 1.3.0.Final
Build tool (ie. output of mvnw --version or gradlew --version): 3.6.3
The text was updated successfully, but these errors were encountered:
Your reproducer project isn't really using the MicroProfile REST Client which the quarkus-rest-client extension provides - you are instead using the JAXRS client.
In any case, I got your reproducer working with the following changes:
diff --git a/src/main/java/org/codependent/RestClient.java b/src/main/java/org/codependent/RestClient.java
index 4bdebac..c3e0100 100644
--- a/src/main/java/org/codependent/RestClient.java
+++ b/src/main/java/org/codependent/RestClient.java
@@ -9,14 +9,17 @@ import javax.ws.rs.core.Response;
@ApplicationScoped
public class RestClient {
- private final Client httpClient;
+ private Client client;
- public RestClient() {
- this.httpClient = ResteasyClientBuilder.newBuilder().build();
+ public Response get() {
+ return getClient().target("https://postman-echo.com/get").request().get();
}
- public Response get() {
- return httpClient.target("https://postman-echo.com/get").request().get();
+ private Client getClient() {
+ if (client == null) {
+ client = ResteasyClientBuilder.newBuilder().build();
+ }
+ return client;
}
}
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index 3c1ac56..30a003c 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -1,2 +1,3 @@
# Configuration file
-# key = value
\ No newline at end of file
+# key = value
+quarkus.native.enable-https-url-handler=true
Describe the bug
The whole context of this problem can be found on Stackoverflow: https://stackoverflow.com/questions/60787675/quarkus-rest-client-cant-be-used-with-applicationscoped-beans-for-native-image
There's a sample project with instructions to reproduce the problem at: https://github.com/codependent/quarkus-rest-client
Expected behavior
The native image should be generated
Actual behavior
Native image generation error:
Configuration
Screenshots
Environment (please complete the following information):
uname -a
orver
: 19.3.0 Darwin Kerneljava -version
: 11.0.6 AdoptOpenJDKmvnw --version
orgradlew --version
): 3.6.3The text was updated successfully, but these errors were encountered: