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

Kafka / Avro class loader issue #16810

Closed
pjgg opened this issue Apr 26, 2021 · 2 comments · Fixed by #16829
Closed

Kafka / Avro class loader issue #16810

pjgg opened this issue Apr 26, 2021 · 2 comments · Fixed by #16829
Assignees
Labels
area/kafka kind/bug Something isn't working
Milestone

Comments

@pjgg
Copy link
Contributor

pjgg commented Apr 26, 2021

Describe the bug

Suddenly beefy-ts/reactive-kafka stop working. Looks that we have a problem related to class loading order.

Scenario
How to reproduce: mvn clean test -pl 301-quarkus-vertx-kafka
Quarkus Version: Upstream
Error message: class io.quarkus.qe.kafka.StockPrice cannot be cast to class org.apache.avro.specific.SpecificRecord

Patch: Add the following property to your application.properties quarkus.test.flat-class-path=true

@pjgg pjgg added the kind/bug Something isn't working label Apr 26, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Apr 26, 2021

/cc @cescoffier

@Ladicek
Copy link
Contributor

Ladicek commented Apr 26, 2021

This is because when locating the Avro schema of the generated class, Avro tries to load the generated class first from the class loader that loaded Avro itself. Only if that fails does Avro consult the TCCL. In the Quarkus architecture, Avro is loaded by the Quarkus base CL, which has the JDK app CL as a parent -- so it can always find the generated classes, because they are on the JVM classpath. Which means that when Avro tries to load the generated class, which is an application class, it is loaded by the Quarkus base CL, instead of the Quarkus application CL.

The generated class is also loaded by the Quarkus app CL, as part of the regular application. So we have it loaded twice, in two different class loaders.

More discussion: https://quarkusio.zulipchat.com/#narrow/stream/187038-dev/topic/Avro.20vs.2E.20continuous.20testing

@stuartwdouglas stuartwdouglas self-assigned this Apr 27, 2021
stuartwdouglas added a commit to stuartwdouglas/quarkus that referenced this issue Apr 27, 2021
This prevents the base runtime CL from
loading deployment classes.

Fixes quarkusio#16810
Fixes quarkusio#16804
gsmet pushed a commit to stuartwdouglas/quarkus that referenced this issue Apr 27, 2021
This prevents the base runtime CL from
loading deployment classes.

Fixes quarkusio#16810
Fixes quarkusio#16804
stuartwdouglas added a commit to stuartwdouglas/quarkus that referenced this issue Apr 27, 2021
This prevents the base runtime CL from
loading deployment classes.

Fixes quarkusio#16810
Fixes quarkusio#16804
stuartwdouglas added a commit to stuartwdouglas/quarkus that referenced this issue Apr 28, 2021
This prevents the base runtime CL from
loading deployment classes.

Fixes quarkusio#16810
Fixes quarkusio#16804
stuartwdouglas added a commit to stuartwdouglas/quarkus that referenced this issue Apr 28, 2021
This prevents the base runtime CL from
loading deployment classes.

Fixes quarkusio#16810
Fixes quarkusio#16804
stuartwdouglas added a commit to stuartwdouglas/quarkus that referenced this issue Apr 28, 2021
This prevents the base runtime CL from
loading deployment classes.

Fixes quarkusio#16810
Fixes quarkusio#16804
@quarkus-bot quarkus-bot bot added this to the 2.0 - main milestone May 4, 2021
Sgitario added a commit to Sgitario/beefy-scenarios that referenced this issue Jun 23, 2021
From quarkusio/quarkus#13154, the `@TestProfile` annotation supports Native tests, therefore the modules 001, 301 and 303 can be extended for Native test coverage.
As part of this work, we have supported also the test resources for Native: quarkusio/quarkus#18077

And also, I've removed the workaround for quarkusio/quarkus#16810 that had been fixed a while ago.

Moreover, for 301:
- We've fixed the native failures and got rid of the application.properties file in the test resources. This can be closed now: quarkusio/quarkus#17829.
- Reduce the number of traces to ease the troubleshot of failures.

And for 303:
- Refactored the test resources to not rely on system properties to load/unload application properties.
pjgg pushed a commit to quarkus-qe/beefy-scenarios that referenced this issue Jul 14, 2021
From quarkusio/quarkus#13154, the `@TestProfile` annotation supports Native tests, therefore the modules 001, 301 and 303 can be extended for Native test coverage.
As part of this work, we have supported also the test resources for Native: quarkusio/quarkus#18077

And also, I've removed the workaround for quarkusio/quarkus#16810 that had been fixed a while ago.

Moreover, for 301:
- We've fixed the native failures and got rid of the application.properties file in the test resources. This can be closed now: quarkusio/quarkus#17829.
- Reduce the number of traces to ease the troubleshot of failures.

And for 303:
- Refactored the test resources to not rely on system properties to load/unload application properties.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kafka kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants