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

Autowiring of beans can cause warning and problem "bean was marked as unused and removed during build" #2519

Closed
JiriOndrusek opened this issue Apr 27, 2021 · 3 comments

Comments

@JiriOndrusek
Copy link
Contributor

Some extension are leveraging extensions, which contains producers for some beans. E.g. google-storage (possibly minio)
Google-storage extension contains StorageProducer, which creates Storage. Camel component autowires Storage into its configuration.
If user tries to leverage this producer with a route using it. It doesn't work and following warning is shown:

================================================================================
CDI: programmatic lookup problem detected
-----------------------------------------
At least one bean matched the required type and qualifiers but was marked as unused and removed during build
Removed beans:
        - PRODUCER_METHOD bean io.quarkiverse.googlecloudservices.storage.runtime.StorageProducer#storage() [types=[com.google.cloud.Service<com.google.cloud.storage.StorageOptions>, interface com.google.cloud.storage.Storage], qualifiers=[@javax.enterprise.inject.Default()]]                                                                                                                                                                                                        
Required type: interface com.google.cloud.storage.Storage
Required qualifiers: []
Solutions:
        - Application developers can eliminate false positives via the @Unremovable annotation
        - Extensions can eliminate false positives via build items, e.g. using the UnremovableBeanBuildItem
        - See also https://quarkus.io/guides/cdi-reference#remove_unused_beans
================================================================================

Problem is caused by the fact, that quartkus does not know about autowired bean and therefore marks producer as unused and removes it.

If I inject bean into my code, quarkus reconizes it, bean is created and autowired into component.

@Inject
    Storage storage;

It would be nice if autowired beans from camel compoinents are recognized by quarkus. This would make configuration of some clients/components much easier for users.

@jamesnetherton
Copy link
Contributor

Related #1387. We can probably make the bean unremovable in our own extension or ask the quarkiverse project to do it for us.

@JiriOndrusek
Copy link
Contributor Author

JiriOndrusek commented Apr 27, 2021

Yes that should work (make bean unremovable), EDIT I'll make bean unremovable in our extension
Just thinking whether it would be possible to "say to quarkus" that some beans are used, therefore there is no need to remove them as unused.

I didn't find #1387, which makes this issue duplicate.

@jamesnetherton
Copy link
Contributor

Duplicate of #1387.

@ppalaga ppalaga added this to the No fix/wont't fix milestone Oct 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants