Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

camel-quarkus-http doesn't build native image - Random/SplittableRandom #2793

Closed
juangon opened this issue Jun 16, 2021 · 7 comments
Closed
Assignees
Milestone

Comments

@juangon
Copy link

juangon commented Jun 16, 2021

When using Quarkus (v 1.13.7, didn't check others) and using http routes (camel-quarkus-http) trying to build native, it throws this error:

Error: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Detected an instance of Random/SplittableRandom class in the image heap. Instances created during image generation have cached seed values and don't behave as expected.  To see how this object got instantiated use --trace-object-instantiation=java.security.SecureRandom. The object was probably created by a class initializer and is reachable from a static field. You can request class initialization at image runtime by using the option --initialize-at-run-time=<class-name>. Or you can write your own initialization methods and call them explicitly from your main entry point.
Detailed message:
Trace: 
	at parsing org.apache.http.impl.auth.NTLMEngineImpl.access$000(NTLMEngineImpl.java:51)
Call path from entry point to org.apache.http.impl.auth.NTLMEngineImpl.access$000(): 
	at org.apache.http.impl.auth.NTLMEngineImpl.access$000(NTLMEngineImpl.java:51)
	at org.apache.http.impl.auth.NTLMEngineImpl$Type3Message.<init>(NTLMEngineImpl.java:1505)
	at org.apache.http.impl.auth.NTLMEngineImpl$Type3Message.<init>(NTLMEngineImpl.java:1474)
	at org.apache.http.impl.auth.NTLMEngineImpl.getType3Message(NTLMEngineImpl.java:181)
	at org.apache.http.impl.auth.NTLMEngineImpl.generateType3Msg(NTLMEngineImpl.java:2097)
	at org.apache.http.impl.auth.NTLMScheme.authenticate(NTLMScheme.java:142)
	at org.apache.http.impl.auth.AuthSchemeBase.authenticate(AuthSchemeBase.java:136)
	at org.apache.http.impl.auth.HttpAuthenticator.doAuth(HttpAuthenticator.java:233)
	at org.apache.http.impl.auth.HttpAuthenticator.generateAuthResponse(HttpAuthenticator.java:213)
	at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:262)
	at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
	at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72)
	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
	at org.apache.camel.component.http.HttpProducer.executeMethod(HttpProducer.java:442)
	at org.apache.camel.component.http.HttpProducer.process(HttpProducer.java:270)
	at org.apache.camel.component.bean.AbstractBeanProcessor.process(AbstractBeanProcessor.java:108)
	at org.apache.camel.processor.DelayProcessorSupport$ProcessCall.run(DelayProcessorSupport.java:71)
	at java.lang.Thread.run(Thread.java:829)
	at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:553)
	at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)
	at com.oracle.svm.core.code.IsolateEnterStub.PosixJavaThreads_pthreadStartRoutine_e1f4a8c0039f8337338252cd8734f63a79b5e3df(generated:0)

@jamesnetherton
Copy link
Contributor

Please can you provide some more information about how your http endpoint is configured.

@juangon
Copy link
Author

juangon commented Jun 16, 2021

Sure @jamesnetherton , there are multiple "to" like this:

.toF("https://%s%s?throwExceptionOnFailure=false&cookieHandler=#instanceCookieHandler&..", a,b)

I have 3 "direct" routes, with some minor exception handling retries like this:

onException(RejectedExecutionException.class)
        .maximumRedeliveries(3).redeliveryDelay(500);

I use choice() , unmarshal, etc too.

@juangon
Copy link
Author

juangon commented Jun 16, 2021

BTw I use a toD too as I need to get some dynamic values from header:

.toD("https://" + url + "ACK?throwExceptionOnFailure=false&cookieHandler=#instanceCookieHandler&ClientKey=${exchangeProperty[key]}")            

@jamesnetherton
Copy link
Contributor

It was the AuthSchemeBase & NTLMScheme parts of the stacktrace that interested me. Do you have any authentication options configured?

@juangon
Copy link
Author

juangon commented Jun 16, 2021

The only auth thing I did was manually set Authorization header like this:

.setHeader("Authorization", constant("Basic " + basicAuth))

@juangon
Copy link
Author

juangon commented Jun 16, 2021

Here is my quarkus and camel-quarkus dependencies:

    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-hibernate-orm</artifactId>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-flyway</artifactId>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-jdbc-mariadb</artifactId>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-resteasy-jsonb</artifactId>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-arc</artifactId>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-oidc</artifactId>
    </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>      
      <artifactId>quarkus-smallrye-reactive-messaging-kafka</artifactId>
    </dependency>
  <dependency>
      <groupId>org.apache.camel.quarkus</groupId>
      <artifactId>camel-quarkus-timer</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.camel.quarkus</groupId>
      <artifactId>camel-quarkus-log</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.camel.quarkus</groupId>
      <artifactId>camel-quarkus-microprofile-health</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.camel.quarkus</groupId>
      <artifactId>camel-quarkus-microprofile-metrics</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.camel.quarkus</groupId>
      <artifactId>camel-quarkus-http</artifactId>
    </dependency>  
    <dependency>
      <groupId>org.apache.camel.quarkus</groupId>
      <artifactId>camel-quarkus-kafka</artifactId>
    </dependency>    

    <dependency>
      <groupId>org.apache.camel.quarkus</groupId>
      <artifactId>camel-quarkus-jackson</artifactId>
    </dependency>    

    <dependency>
      <groupId>org.apache.camel.quarkus</groupId>
      <artifactId>camel-quarkus-bean</artifactId>
    </dependency>    

    <dependency>
      <groupId>org.apache.camel.quarkus</groupId>
      <artifactId>camel-quarkus-direct</artifactId>
    </dependency>  

    <dependency>
      <groupId>org.apache.camel.quarkus</groupId>
      <artifactId>camel-quarkus-jsonpath</artifactId>
    </dependency>  

    <!-- FOR LOCALDATETIME MARSHAL/UNMARSHAL-->
    <dependency>
      <groupId>com.fasterxml.jackson.datatype</groupId>
      <artifactId>jackson-datatype-jsr310</artifactId>
    </dependency>

@jamesnetherton
Copy link
Contributor

Unfortunately we lack native test coverage for authentication (#2794). So this issue was not noticed.

As a workaround, you could try adding this configuration property to application.properties.

quarkus.native.additional-build-args = --initialize-at-run-time=org.apache.http.impl.auth.NTLMEngineImpl

@jamesnetherton jamesnetherton self-assigned this Jun 16, 2021
@jamesnetherton jamesnetherton added this to the 2.0.0 milestone Jun 16, 2021
jamesnetherton added a commit to jamesnetherton/camel-quarkus that referenced this issue Jun 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants