-
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
ClassTooLargeException when building an application containing many CDI beans #45380
Comments
13 000 CDI beans? That's quite a number for a Quarkus app. Do you really use all those classes as fully fledged beans? |
Dear, mkouba We have recently migrated our application from Payara 6 to Quarkus. As this is a large and continuously evolving project, the number of CDI beans is expected to increase over time. A significant portion of these CDI beans comes from the clean code patterns we are following. We did not anticipate any restrictions on the number of CDI beans, and we couldn’t find any documentation indicating a maximum limit on the beans. Could you please clarify whether there are any implicit constraints on the number of CDI beans, or if this could be a potential bug? |
There are no hard limits but 13K beans is way bigger than the usual microservice use case. In Quarkus, we do generate a lot of metadata classes and in case of CDI we need to generate a class that wires all dependencies together - the Just out of curiosity - what patterns are you following? Also would it be possible to split your application into several smaller modules? I'm pretty sure it would have other benefits too. |
Could we split I'm totally in line that this is an edge case and I'm not entirely sure it would scale very well but I'm not sure either having a hard limit that is hard to document is a good thing. Especially since you could hit it after your migration to Quarkus when adding some additional beans. |
This microservice was originally part of a large monolith. From a functional perspective, it follows the Single Responsibility Principle. It is not a small project, but the concept of a microservice here is understood not as a small piece of code running somewhere, but as a single, responsible unit. We understand that 13000 beans is quite a lot. However, this comes from following the SOLID principles, where we aim to have as many single-responsibility classes as possible. This approach naturally results in a higher number of beans. That's why I think the Default_ComponentsProvider serving as the single location for managing all dependencies could potentially be slightly optimized to handle a large number of beans more effectively. |
Thank you for answering. |
Just for our information, how long does the legacy application take to startup? |
The startup time is ~ 8/9 seconds |
Thanks for the info |
Thank you for your interest in this topic! I would also truly appreciate any insights on whether you see this as a bug and if there are any plans to address it. Understanding whether a fix is expected would help us determine the next steps and how to proceed. My intention is not to apply any pressure but simply to gain a better understanding of the situation. Thanks, everyone! |
@mkouba is going to check and see if it can fixed |
Very much appreciate it :) |
Describe the bug
During the build phase of the application, we are getting a ClassTooLargeException
The number of CDI beans is ~ 13000 and it will be increasing!
We have a multi-module project heavily dependent on CDI.
We are using the quarkus-maven-plugin
This is the list of quarkus dependencies:
Expected behavior
Successful build
Actual behavior
How to Reproduce?
In out project, we currently have ~ 13000 CDI beans
I expect that you need to create a lot of @dependent beans!
Not sure whether the size of the beans class itself matters!
Output of
uname -a
orver
OS name: "mac os x", version: "14.7.1", arch: "aarch64", family: "mac"
Output of
java -version
OpenJDK 64-Bit Server VM Corretto-17.0.7.7.1 (build 17.0.7+7-LTS, mixed mode, sharing)
Quarkus version or git rev
3.17.5
Build tool (ie. output of
mvnw --version
orgradlew --version
)Apache Maven 3.8.6
Additional information
No response
The text was updated successfully, but these errors were encountered: