java.util.ServiceConfigurationError: io.smallrye.config.SmallRyeConfigFactory when injecting same configuration parameter in multiple test classes
See original GitHub issueDescribe the bug
When injecting a config property annotated with @Configproperty(name = 'myproperty') and @Inject in two separate Test classes, it will run the test fine on the first class, but on the second class it will throw the following exception:
<output of testclass1 truncated>
[INFO] Tests run: 10, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 9.418 s - in dev.testclass1.ObjectsAzureImplTest
[INFO] Running dev.testclass2.RepositoriesAzureImplTest
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.001 s <<< FAILURE! - in dev.testclass2.RepositoriesAzureImplTest
[ERROR] dev.testclass2.RepositoriesAzureImplTest Time elapsed: 0.001 s <<< ERROR!
org.junit.jupiter.api.extension.TestInstantiationException: Failed to create test instance
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
Caused by: java.lang.reflect.InvocationTargetException
Caused by: java.util.ServiceConfigurationError: io.smallrye.config.SmallRyeConfigFactory: io.quarkus.runtime.configuration.QuarkusConfigFactory not a subtype
2020-03-27 09:07:01,704 INFO [io.quarkus] (main) Quarkus stopped in 0.033s
[INFO]
[INFO] Results:
[INFO]
[ERROR] Errors:
[ERROR] RepositoriesAzureImplTest » TestInstantiation Failed to create test instance
[INFO]
[ERROR] Tests run: 11, Failures: 0, Errors: 1, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.404 s
[INFO] Finished at: 2020-03-27T09:07:02+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test)
Disabling one of the two test classes means both classes run fine, so the tests themselves have no error. After removing the @Inject and @Configproperty(name = 'myproperty'), and hardcoding the value, both tests are running as expected. So the problem is clearly in the injection mechanism.
Note that this behavior was not with Quarkus 1.2 and started after upgrading to Quarkus 1.3
Expected behavior
I can inject the myproperty set in applications.properties across multiple test classes and have my test classes all succeed.
Actual behavior Currently this injection only works for one class, and will fail once the second test class is starting.
To Reproduce Steps to reproduce the behavior:
- Create two separate test classes and a config parameter in application.properties
- Inject the parameter in both test classes
- Watch the first test succeed, and the second one fail. Run them individually and the test cases both succeed.
Environment (please complete the following information):
- Quarkus version or git rev: 1.3.0
- Build tool (ie. output of
mvnw --versionorgradlew --version):
Maven home: /home/jorn/.m2/wrapper/dists/apache-maven-3.6.3-bin/1iopthnavndlasol9gbrbg6bf2/apache-maven-3.6.3
Java version: 11.0.6, vendor: AdoptOpenJDK, runtime: /opt/jdk-11.0.6+10
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "4.19.84-microsoft-standard", arch: "amd64", family: "unix"
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (4 by maintainers)
Top Related StackOverflow Question
I had the same error when testing with a Main application that involves parallel().stream(). If I remove parallel(), then test does its work without exceptions. PS Launching the main from quarkus:dev() return me no error
I am receiving this issue with 1.13.1.Final. In my case it is triggered trying to load the JwtEncryptionBuilder class which is part of quarkus-smallrye-jwt-build.