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

RestClient: NullPointerException: Cannot read field "skipPattern" because "this.tracingConfig" is null #3142

Closed
ennishol opened this issue Sep 30, 2021 · 9 comments
Assignees

Comments

@ennishol
Copy link

ennishol commented Sep 30, 2021

When using open tracing and microprofile rest client I get the error:

java.lang.NullPointerException: Cannot read field "skipPattern" because "this.tracingConfig" is null
	at io.quarkus.smallrye.opentracing.runtime.QuarkusSmallRyeTracingDynamicFeature.configure(QuarkusSmallRyeTracingDynamicFeature.java:26)
	at org.jboss.resteasy.client.jaxrs.internal.proxy.ClientInvoker.<init>(ClientInvoker.java:87)
	at org.jboss.resteasy.client.jaxrs.internal.proxy.ProxyBuilderImpl.createClientInvoker(ProxyBuilderImpl.java:50)
	at org.jboss.resteasy.client.jaxrs.internal.proxy.ProxyBuilderImpl.build(ProxyBuilderImpl.java:149)
	at org.jboss.resteasy.client.jaxrs.internal.proxy.ProxyBuilderImpl.build(ProxyBuilderImpl.java:108)
	at io.quarkus.restclient.runtime.QuarkusRestClientBuilder.build(QuarkusRestClientBuilder.java:339)
	at io.quarkus.restclient.runtime.RestClientBase.create(RestClientBase.java:69)
	at org.acme.observability.ChuckNorrisService_79fd6a8cbc68c8d6ace72dc55beac63165c8b1e7_Synthetic_Bean.create(ChuckNorrisService_79fd6a8cbc68c8d6ace72dc55beac63165c8b1e7_Synthetic_Bean.zig:225

Some logs:

2021-09-30 12:22:23,380 WARN  [io.qua.arc.dep.SplitPackageProcessor] (build-14) Detected a split package usage which is considered a bad practice and should be avoided. Following packages were detected in multiple archives: 
- "org.apache.camel.main" found in [org.apache.camel:camel-base-engine::jar, org.apache.camel:camel-main::jar]
2021-09-30 12:22:25,040 WARN  [io.qua.arc.impl] (Quarkus Main Thread) 
================================================================================
CDI: programmatic lookup problem detected
-----------------------------------------
At least one bean matched the required type and qualifiers but was marked as unused and removed during build
Removed beans:
        - null bean null [types=[interface javax.ws.rs.container.DynamicFeature, class io.quarkus.smallrye.opentracing.runtime.QuarkusSmallRyeTracingDynamicFeature], qualifiers=null]
Required type: class io.quarkus.smallrye.opentracing.runtime.QuarkusSmallRyeTracingDynamicFeature
Required qualifiers: [@javax.enterprise.inject.Default()]
Solutions:
        - Application developers can eliminate false positives via the @Unremovable annotation
        - Extensions can eliminate false positives via build items, e.g. using the UnremovableBeanBuildItem
        - See also https://quarkus.io/guides/cdi-reference#remove_unused_beans
================================================================================

Reproducer observability.tar.gz

  1. tar -xvpzf observability.tar.gz
  2. cd observability/
  3. mvn quarkus:dev
  4. browse http://localhost:8080/api/joke
  5. or execute mvn test

Update: when fixed, update route in Route.java to make the output work

        rest("/api/")
                .get("/joke")
                .produces("application/json")
                .route()
                  .process(exchange -> exchange.getIn().setBody(jokes.joke()))
                  .marshal().json(JsonLibrary.Jsonb)
                .endRest();

and add dependency

        <dependency>
            <groupId>org.apache.camel.quarkus</groupId>
            <artifactId>camel-quarkus-jsonb</artifactId>
        </dependency>
@ennishol
Copy link
Author

When I remove camel-quarkus-opentracing and corresponding config and @Traced annotations, then the application works fine

@jamesnetherton
Copy link
Contributor

The workaround is to set a configuration property:

quarkus.arc.unremovable-types=io.quarkus.smallrye.opentracing.runtime.QuarkusSmallRyeTracingDynamicFeature

I need to dig into the problem a bit further. Seems strange that Quarkus is removing a type when the Camel extension is present.

@jamesnetherton jamesnetherton self-assigned this Sep 30, 2021
@jamesnetherton jamesnetherton added this to the 2.4.0 milestone Sep 30, 2021
@jamesnetherton
Copy link
Contributor

@ennishol You may want to raise a Quarkus issue for this.

The same warning is present when you remove all of the Camel Quarkus dependencies and add quarkus-smallrye-opentracing. So it seems to be a general Quarkus OpenTracing issue, unrelated to Camel Quarkus.

@jamesnetherton jamesnetherton removed this from the 2.4.0 milestone Sep 30, 2021
@ennishol
Copy link
Author

ennishol commented Oct 1, 2021

@jamesnetherton I created equivalent quarkus project and it works just fine. So, it seems that it is the combination of quarkus and camel is the problem

@jamesnetherton
Copy link
Contributor

Ok, I can take another look.

@jamesnetherton jamesnetherton reopened this Oct 1, 2021
@jamesnetherton
Copy link
Contributor

@ennishol The issue probably occurs because in your Camel application you do not have quarkus-resteasy on the classpath. AFAIK JAX-RS DynamicFeature applies to the server side. So if the JAX-RS server bits aren't there, then I guess QuarkusSmallRyeTracingDynamicFeature gets removed.

Not sure it's really Camel Quarkus at fault here. There is no hard requirement for RestEasy in Camel.

I could make QuarkusSmallRyeTracingDynamicFeature unremovable in our OpenTracing extension if there's no RestEasy present, which would probably solve the problem.

@jamesnetherton
Copy link
Contributor

I could make QuarkusSmallRyeTracingDynamicFeature unremovable in our OpenTracing extension if there's no RestEasy present, which would probably solve the problem.

Thinking that through some more. It'd be a hack & not a true fix. So it's Quarkus that should handle RestEasy not being present, if that is actually a valid scenario.

@ennishol
Copy link
Author

ennishol commented Oct 1, 2021

@jamesnetherton Thanks for looking into it. I added resteasy extension and now that fixed the problem

@gsmet
Copy link
Contributor

gsmet commented Jan 5, 2022

It has finally been fixed in Quarkus here: quarkusio/quarkus#22609 .

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

3 participants