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

io.quarkus.qute.i18n.MessageBundle annotated class *__Bundle not found for multi-module gradle project in test mode #20064

Closed
nikosk686 opened this issue Sep 10, 2021 · 14 comments · Fixed by #20204
Assignees
Labels
area/gradle Gradle area/qute The template engine kind/bug Something isn't working
Milestone

Comments

@nikosk686
Copy link

Describe the bug

Kind of related to this

In a similar multi-module gradle setup,
when we use a @MessageBundle annotated class

@MessageBundle(value = "alert")
public interface AlertMessages {

@Message("")
String withoutParams();

@Message("")
String withParams(String name);

}
with several localized implementations generated from the provided messages/alert_xx.properties files
we get the following error when trying to run the integration tests in the integration-test sub-module in test mode

Caused by: java.lang.NoClassDefFoundError: org/acme/AlertMessages_Bundle

This error does not affect single module projects.

Expected behavior

The integration tets should be able to be executed in test mode as it happens in a single module project.

Actual behavior

The application fails to start in test mode

Caused by: java.lang.RuntimeException: Failed to start quarkus
...
Caused by: java.lang.NoClassDefFoundError: org/acme/AlertMessages_Bundle

How to Reproduce?

clone the following repo https://github.com/nikosk686/quarkus-message-bundle-poc
checkout the 2.2.0-multi-module-integration-tests-error branch
and try to run the test located in the integration-test sub-module

You can also check the master branch which is a single module application and test runs correctly.

Output of uname -a or ver

Linux dell-desktop 5.10.0-1045-oem #47-Ubuntu SMP Wed Aug 18 10:41:03 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Output of java -version

openjdk version "11.0.10" 2021-01-19 LTS OpenJDK Runtime Environment Corretto-11.0.10.9.1 (build 11.0.10+9-LTS) OpenJDK 64-Bit Server VM Corretto-11.0.10.9.1 (build 11.0.10+9-LTS, mixed mode)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.2.0

Build tool (ie. output of mvnw --version or gradlew --version)

Gradle 6.9

Additional information

The problem is not present in quarkus v1 (run the test in the integration-test sub-module in the 1.13.7-working-single-module branch of the above repo, it should pass)

@nikosk686 nikosk686 added the kind/bug Something isn't working label Sep 10, 2021
@quarkus-bot quarkus-bot bot added area/gradle Gradle area/qute The template engine labels Sep 10, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Sep 10, 2021

/cc @glefloch, @mkouba, @quarkusio/devtools

@nikosk686
Copy link
Author

A follow-up on this.
Running the test with the -Dquarkus.debug.generated-classes-dir=build/dump-generated-classes property
I can see that synthetic beans are generated.
quarkus-qute-220-error

I don't know if it helps but the error seems to be thrown from https://github.com/quarkusio/quarkus/blob/main/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/AbstractSharedContext.java#L96
and specifically from the bean.create(creationalContext) call.

Also, I have tried a similar multi-module setup like the one in the example above but this time using maven and it seems that the issue is also present there.

@mkouba
Copy link
Contributor

mkouba commented Sep 16, 2021

It would be helpful if you could share the maven version of the reproducer as well.

@nikosk686
Copy link
Author

@mkouba thanks.
here it is https://github.com/nikosk686/quarkus-message-bundle-poc-maven
you should be able to run successfully the following
./mvnw clean test -Dquarkus.debug.generated-classes-dir=target/dump-generated-classes
in the master branch, in which the test is in the same submodule with the @MessageBundle interface
but it will fail in the multi-module-error branch where the test resides in the integration-test submodule.

Also checking the generated sources and based on my above comment I see that the problem is in the
generated AlertMessages_51773f036f9f1555656dca9c292fdac673967c51_Synthetic_Bean class.
There in the create method we have

public AlertMessages create(CreationalContext var1) {
        return (AlertMessages)(new AlertMessages_Bundle());
    }

and we get the error

Caused by: java.lang.RuntimeException: Failed to start quarkus
Caused by: java.lang.NoClassDefFoundError: org/acme/AlertMessages_Bundle
Caused by: java.lang.ClassNotFoundException: org.acme.AlertMessages_Bundle

however if you check the screenshot you'll see that the org.acme.AlertMessages_Bundle has been generated.

@mkouba
Copy link
Contributor

mkouba commented Sep 16, 2021

however if you check the screenshot you'll see that the org.acme.AlertMessages_Bundle has been generated.

Yes, it's definitely some weird class loading problem. Let me check your reproducer first...

@mkouba
Copy link
Contributor

mkouba commented Sep 16, 2021

So for some reason the org.acme:api dependency is considered a library, and not an application archive when executing the tests. quarkus.class-loading.reloadable-artifacts=org.acme:api in application.properties can be used to work around the problem. @aloubyansky Do you have an idea what could be wrong?

BTW I think that the parent pom shouldn't define the <dependencies> - these should be placed in the pom of a specific module.

@nikosk686
Copy link
Author

Thanks, @mkouba let me try and I ll come back.
About the pom dependencies, I agree but I just wanted a quick and dirty demo.
I use gradle anyway in the project that I have this issue, as I explain in the first comment.

@nikosk686
Copy link
Author

nikosk686 commented Sep 16, 2021

@mkouba the quarkus.class-loading.reloadable-artifacts=org.acme:api workaround works with the maven project.
Does not seem to have any impact on the Gradle project though :(

@aloubyansky
Copy link
Member

I can see it being added to the ApplicationArchivesBuildItem as

org.acme:api::jar [paths: /home/aloubyansky/playground/quarkus-message-bundle-poc-maven/api/target/classes;]

@nikosk686
Copy link
Author

nikosk686 commented Sep 16, 2021

Does not seem to have any impact on the Gradle project though :(

Sorry I was wrong I have a typo in my gradle poc and the group name is org.org.acme
some quarkus.class-loading.reloadable-artifacts=org.org.acme:api works in my gradle project which is good enough for me!

@mkouba
Copy link
Contributor

mkouba commented Sep 16, 2021

I can see it being added to the ApplicationArchivesBuildItem as

org.acme:api::jar [paths: /home/aloubyansky/playground/quarkus-message-bundle-poc-maven/api/target/classes;]

@aloubyansky I think I can see the problem - ArC and Qute have a slightly different application class predicate implementation (used by the io.quarkus.deployment.GeneratedClassGizmoAdaptor). I'll try to explore this path further...

@mkouba mkouba self-assigned this Sep 16, 2021
@mkouba mkouba added this to the 2.3 - main milestone Sep 16, 2021
mkouba added a commit to mkouba/quarkus that referenced this issue Sep 16, 2021
@mkouba
Copy link
Contributor

mkouba commented Sep 16, 2021

@nikosk686 #20204 should fix the problem. Keep in mind that you would have to move the quarkus-maven-plugin definition from the parent to the api module otherwise you'd run into different type of problems ;-).

@pipinet
Copy link

pipinet commented Nov 22, 2021

@mkouba
hi, same error in gradle multi module, How to fix it?

@mkouba
Copy link
Contributor

mkouba commented Nov 23, 2021

@mkouba hi, same error in gradle multi module, How to fix it?

What version of quarkus do you use?

@gsmet gsmet modified the milestones: 2.3.0.CR1, 2.2.4.Final Nov 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/gradle Gradle area/qute The template engine kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants