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

Fails to create resource instance when injecting @Context into constructor having bean-discovery-mode="none" on Jersey 2.30 #4777

Closed
mkarg opened this issue Apr 21, 2021 · 1 comment · Fixed by #4779
Labels
bug Something isn't working cdi injection

Comments

@mkarg
Copy link
Member

mkarg commented Apr 21, 2021

Problem Description

When a resource class is located in a WAR file which declares bean-discovery-mode="none" in beans.xml and that resource class has a constructor parameter annotated with @Context, then bootstrapping of the resource fails with the following error message: WELD-001530: Cannot produce an instance of class

Environment

  • Java 8
  • Jersey 2.30 as part of Payara Community Edition 5.2021.2
  • It seems this bug exists since rather long time (not just since 2.23), as it was reported on Stack Overflow more than four years ago.

Workaround

  • Replace constructor by @PostConstruct-annotated method (and in turn, use field injection)
@jansupol jansupol added bug Something isn't working injection cdi labels Apr 22, 2021
@mkarg
Copy link
Member Author

mkarg commented Apr 23, 2021

Thanks a lot Jan, for resolving this issue such quickly!

@mkarg mkarg changed the title Fails to create resource instance when injecting @Context into constructor having bean-discovery-mode="none" on Jersey 2.23 Fails to create resource instance when injecting @Context into constructor having bean-discovery-mode="none" on Jersey 2.30 Apr 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cdi injection
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants