-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Removal of beans loads referenced classes #24338
Comments
If the bean is removed then it's not excluded from discovery. I'm not sure whether quarkus honors dependency exclusions in a multi-module app. CC @aloubyansky |
It does, hence the CNFE. I am not sure if ArC can handle this by not loading the class that appears to be an unused bean. |
I'm sorry but I don't understand. If it does then ArC should not see the bean class at all... in other words, it should not be part of the app index. |
Here is the exclusion
The bean is in the |
Hm, so the issue is that As far as I know, we use these removed beans in two places. In this scenario, wouldn't it instead make more sense to exclude the bean (or the JAR) from bean discovery somehow? |
I see. Well, in that case it's an invalid use case because there is a bean declared but not all bean types are loadable (AFAIK Weld does ignore similar classes and logs some warning). @Postremus you can try to exclude the bean class from discovery via the quarkus.arc.exclude-types config property.
Yep, |
Yeah, that's what I meant! I knew we had something but couldn't remember :) |
Not sure if it's worth it and how complex this is, could this be considered a kind of optimization to load the classes of unused beans lazily, given that it's probably rare when they have to be loaded at the end? |
We have an open issue for this optimization: #18345, but the priority is low due to the impact and the fact that you can also set |
That works. However, could you please add an actionable error message? |
Hm, that's not so easy. I mean the CNFE is a generic error that can occur in many places. We could catch the error in the generated |
I've tried to implement something and then I realized that we share the loaded types for removed beans and this optimization (1) means that we can assign a CNFE to the first component that uses the type, (2) makes it really difficult to implement this elegantly. I'll try to come with something but given the impact it has and a trivial workaround exists I'd consider this a low priority issue.. |
- log a warning if unable to load a bean type of a removed bean - previously the app failed at startup - resolves quarkusio#24338
- log a warning if unable to load a bean type of a removed bean - previously the app failed at startup - resolves quarkusio#24338
Describe the bug
I have following project structure:
The commons module includes hibernate-validator (and custom ConstraintValidators), which I just don't need for this project.
I tried to simply add an exclusion on quarkus-hibernate-validator, to remove this extension.
However, I got the exception from below.
Apperantly, during removal of unused beans, the bean is initialized?
Expected behavior
App starts, just with the ConstraintValidator removed.
Actual behavior
How to Reproduce?
Download the reproducer:
removed-bean-classloading.zip
Output of
uname -a
orver
Microsoft Windows [Version 10.0.19044.1586]
Output of
java -version
openjdk 17.0.2 2022-01-18 OpenJDK Runtime Environment Temurin-17.0.2+8 (build 17.0.2+8) OpenJDK 64-Bit Server VM Temurin-17.0.2+8 (build 17.0.2+8, mixed mode, sharing)
GraalVM version (if different from Java)
No response
Quarkus version or git rev
2.7.4.Final
Build tool (ie. output of
mvnw --version
orgradlew --version
)Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537) Maven home: C:\eclipse\tools\java\maven Java version: 17.0.2, vendor: Eclipse Adoptium, runtime: C:\eclipse\tools\java\17 Default locale: de_DE, platform encoding: Cp1252 OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
Additional information
No response
The text was updated successfully, but these errors were encountered: