since 3.21.4@InjectMock JsonWebToken jwt fails with ContextNotActiveException, it was running in 3.21.3
org.junit.jupiter.api.extension.TestInstantiationException: Failed to create test instance
at io.quarkus.test.junit.QuarkusTestExtension.initTestState(QuarkusTestExtension.java:767)
at io.quarkus.test.junit.QuarkusTestExtension.interceptTestClassConstructor(QuarkusTestExtension.java:733)
at java.base/java.util.Optional.orElseGet(Optional.java:364)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
Caused by: jakarta.enterprise.context.ContextNotActiveException: RequestScoped context was not active when trying to obtain a bean instance for a client proxy of PRODUCER_METHOD bean [class=io.quarkus.smallrye.jwt.runtime.auth.JwtPrincipalProducer, id=BxDM8UQSQwnNG8ZE6VKFZ8wrsgg]
- you can activate the request context for a specific method using the @ActivateRequestContext interceptor binding
Expected behavior
should work imho as @InjectMock should somehow replace the real implementation bound to @RequestScope
Describe the bug
since
3.21.4
@InjectMock JsonWebToken jwt
fails with ContextNotActiveException, it was running in3.21.3
Expected behavior
should work imho as
@InjectMock
should somehow replace the real implementation bound to@RequestScope
Actual behavior
fails with exception above
How to Reproduce?
https://github.com/flyinfish/quarkus--inject-mock-jwt
Workaround
there is a workaround JwtBeanInjectMockWorkaroundTest still running which installs the mock dynamically with
QuarkusMock.installMockForType()
Output of
uname -a
orver
Linux C70C7391 5.15.167.4-microsoft-standard-WSL2 #1 SMP Tue Nov 5 00:21:55 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
Output of
java -version
openjdk 21.0.7 2025-04-15 LTS OpenJDK Runtime Environment Zulu21.42+20-SA (build 21.0.7+6-LTS) OpenJDK 64-Bit Server VM Zulu21.42+20-SA (build 21.0.7+6-LTS, mixed mode, sharing)
Quarkus version or git rev
3.21.4
Build tool (ie. output of
mvnw --version
orgradlew --version
)Apache Maven 3.9.9 (8e8579a9e76f7d015ee5ec7bfcdc97d260186937) Maven home: /opt/apache-maven-3.9.9 Java version: 21.0.7, vendor: Azul Systems, Inc., runtime: /usr/lib/jvm/mobi-azuljdk21 Default locale: en, platform encoding: UTF-8 OS name: "linux", version: "5.15.167.4-microsoft-standard-wsl2", arch: "amd64", family: "unix"
Additional information
No response