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

Quarkus/Gradle/Application class CDI issue - Injected variable is null during test step #17441

Closed
bogedal opened this issue May 25, 2021 · 8 comments
Labels
area/arc Issue related to ARC (dependency injection) area/gradle Gradle kind/bug Something isn't working triage/invalid This doesn't seem right

Comments

@bogedal
Copy link

bogedal commented May 25, 2021

Describe the bug

During the test step of gradle the test fails with a nullpointer exception on the injected variable in the Application class.

To Reproduce

reproducer.zip

Steps to reproduce the behavior:

  1. execute gradle build

Environment (please complete the following information):

Output of java -version

Java version "11.0.10" 2021-01-19 LTS

Quarkus version or git rev

Quarkus version 1.13.4.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Gradle 6.8.3

@bogedal bogedal added the kind/bug Something isn't working label May 25, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented May 25, 2021

/cc @glefloch, @manovotn, @mkouba, @quarkusio/devtools

@quarkus-bot quarkus-bot bot added area/arc Issue related to ARC (dependency injection) area/gradle Gradle labels May 25, 2021
@geoand
Copy link
Contributor

geoand commented May 25, 2021

This is a limitation of JAX-RS, you can't inject stuff via CDI into a JAX-RS Application class

@bogedal
Copy link
Author

bogedal commented May 25, 2021

@geoand That sounds odd. I have several Helidon based services running with injected stuff in the JAX-RS application class.

@geoand
Copy link
Contributor

geoand commented May 25, 2021

Sure, I'm not saying it can't be done technically.

What I am saying is that because reads this class at build time, injection does not work

geoand added a commit to geoand/quarkus that referenced this issue May 25, 2021
@bogedal
Copy link
Author

bogedal commented May 25, 2021

@geoand Do you mean that Quarkus reads this class at build time?

@geoand
Copy link
Contributor

geoand commented May 25, 2021

@geoand Do you mean that Quarkus reads this class at build time?

Yes, for RESTEasy Reactive at least.

For RESTEasy Classic, I am not sure, but in any case it's likely read too early for CDI to work

@bogedal
Copy link
Author

bogedal commented May 25, 2021

Ok - Thanks a lot for the very quick responses :)

@geoand
Copy link
Contributor

geoand commented May 25, 2021

I have a opened a PR to make this a build time error in RESTEasy Reactive.

@geoand geoand closed this as completed May 25, 2021
@geoand geoand added the triage/invalid This doesn't seem right label May 25, 2021
geoand added a commit to geoand/quarkus that referenced this issue May 25, 2021
gsmet added a commit that referenced this issue May 25, 2021
Fail at build time if @Inject is used in JAX-RS Application class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/arc Issue related to ARC (dependency injection) area/gradle Gradle kind/bug Something isn't working triage/invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants