-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
GraalVM error with Micronaut 3: Multiple possible bean candidates found: io.micronaut.aop.InterceptorRegistry #6579
Comments
Running the agent means you get duplicate classes registered with GraalVM since they are registered already via service loader and then again via the native image metadata. You can resolve this by adding:
Or deleting all of the entries ending with |
Thanks @graemerocher That actually fixed my issue. I'll let it up you to decide if this is only a documentation issue or something should actually be fixed because it worked with Micronaut 2.5.x out-of-the-box. |
It actually didn't work in 2.5.x you actually ended up with duplicate beans everywhere but there just happened to not manifest as a non unique bean exception by chance |
How do you configure these build args in maven |
|
I tried this but that did not work. The following is my configuration |
Thanks @rodrigar-mx for your support. What we noticed is that the |
We are getting this same error, but aren't using native/GraalVM at all. It all worked fine in Micronaut 2.5.x, We started getting this error when we upgraded to 3.2.7 and get the same behavior with 3.3. as well. This is part of a thick client (using Swing) that uses a REST client to access services we stand up in a separate VM on localhost.
Here's the weird part. SAFEAnalyzerServiceImpl is a Singleton. I changed it to add @primary (which is sensible for it anyway), This only happens when we run old Jemmy/JUnit4-based GUI integration tests (yeah, I know, we're stuck with that). The services seem to run fine otherwise. After adding @primary the behavior changes a bit. If we do a clean checkout of the project and run the Jemmy integration tests, they still fail with the above error. However, they then pass on subsequent runs (using gradlew --refresh-dependencies clean test), and we're baffled why. Maybe we're doing something wrong standing up our Jemmy tests - so I am investigating that - but this didn't start until Micronaut 3.x. |
I am facing same error above things didn't worked for me. I am facing it with Repository. more details are at https://stackoverflow.com/questions/71665667/micronaut-error-multiple-possible-bean-candidates-found-io-micronaut-aop-int
|
I'm running into the same error (NOT using native/Graal). Currently upgrading from micronaut 2 -> 3.4.1. Did not have this error in MN 2. Message: Multiple possible bean candidates found: [io.micronaut.aop.InterceptorRegistry, io.micronaut.aop.InterceptorRegistry, io.micronaut.aop.InterceptorRegistry, io.micronaut.aop.InterceptorRegistry...] I'm using the micronaut library Gradle plugin to build libraries, and the micronaut application Gradle plugin to build a service that is dependent on those libraries. The class throwing the error is an @singleton, but it appears it might have to do with injecting an interface using the @client annotation which extends an interface containing REST methods. |
I'm facing the same error in Micronaut 3.4.1 but only when the application is running in a Docker container (locally or in Kubernetes):
It happens only for When I try to inject
|
I worked around this by downgrading to Micronaut 3.3.2. This commit looks related but idk haha.
|
This is a significant change that alters Micronaut so that instead of a single registry of type names contains in META-INF/services entries a directory is created with file names of each type within META-INF/micronaut instead. The benefit of this change is that we can now fully incrementally compile and avoid completely re-running the annotation processors on each change to an annotated type. We also simplify our annotation processing pipeline with the downstream service generating processor no longer necessary. The change has implications to AOT and other areas but I don't consider it breaking as Micronaut will continue to work as previously with the change. This change also addresses issues with Graal since we abuse META-INF/services by storing types that cannot actually be loaded with the standard Java service loader (Micronaut's bean references can reference types that not on the classpath). This should also address improve the situation with #6579 Co-authored-by: Sergio del Amo <[email protected]>
None of the above worked for me. I resolved the issue by adding an access filter as described here: https://www.graalvm.org/22.0/reference-manual/native-image/Agent/#access-filters, the access filter: { "rules": [
{"excludeClasses": "io.micronaut.**"}
]
} Then I removed all resources containing |
Posting this here incase others can benefit from what work around helped me overcome this. As the error suggests there were multiple versions of the AOP library/jar being included, the dependency report showed that even though I was running micronaut 3.8.2, version 3.7.4 of aop was being included through the mac osx runtime dependency. Adding the following the dependencies of build.gradle stops this error from appearing, but I'm not convinced it is addressing the root cause of why this starting happening for me.
|
Hey guys i think i found the reason. |
right, the reason is normally a classpath issue where you have multiple versions of the same JAR on your classpath |
For others searching for a solution, and that don't have different versions of micronaut on the classpath. This can also happen when you have multiple modules, solved it by disabling shading in a child module: #10251 (comment) |
I have this issue, i do not have multiple micronaut versions on my classpath and i do not have child modules. EditTurns out that i had this exact same issue years ago and i forgot that. The issue was only reproducible in integration tests, adding this configuration to the failsafe plugin solved that: <configuration>
<classesDirectory>${project.build.outputDirectory}</classesDirectory>
</configuration> |
Expected Behavior
Building and executing the native image of the provided and minimal application should succeed. Actually, it was successful on Micronaut 2.5.x but fails since Micronaut 3.0.0
The bug is triggered by injecting a configuration interface:
into a class which is annotated with
@Context
:and building and executing the native image based on a generated native image configuration.
The error message is the same as in #6406 but they don't seem to be related.
Actual Behaviour
build/native/nativeCompile/context
fails withSteps To Reproduce
git clone https://github.com/tobiasschaefer/bug-interceptor-registry.git
Setup
Create the native image configuration with the following steps and cancel with Ctrl-C when the application is running:
(or simply execute the provided script
./create-reflection-config.sh
)Create image with
./gradlew clean nativeCompile
Starting the native application with
build/native/nativeCompile/context
fails with the error mentioned above.Environment Information
Example Application
https://github.com/tobiasschaefer/bug-interceptor-registry.git
Version
3.2.0
The text was updated successfully, but these errors were encountered: