java.util.ServiceConfigurationError: io.smallrye.config.SmallRyeConfigFactory when injecting same configuration parameter in multiple test classes

See original GitHub issue

Describe 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:

  1. Create two separate test classes and a config parameter in application.properties
  2. Inject the parameter in both test classes
  3. 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 --version or gradlew --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:closed
  • Created 3 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
fstarredcommented, Mar 4, 2022

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

0reactions
independentidcommented, Apr 14, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting Started - SmallRye Config
Getting Started#. Config Sources#. By default, SmallRye Config reads configuration properties from multiple configuration sources (by descending ordinal):.
Read more >
smallrye - Bountysource
Hi,. I have a project that uses smallrye-config and I am trying to port it to a willdfly 23 installation which does not...
Read more >
Quarkus 1.13.x WebSocket Client - wrong ClassLoader?
java.lang.RuntimeException: java.util.ServiceConfigurationError: io.smallrye.config.SmallRyeConfigFactory: io.quarkus.runtime.configuration.
Read more >
Red Hat JBoss Enterprise Application Platform 7.4.0.CD19
... io.smallrye.config.common · io.smallrye.config.common.utils · io.smallrye.config.inject ... org.jboss.narayana.txframework.api.configuration.service ...
Read more >
quarkus-bot[bot] - Developer Q&A Platform - PullAnswer
Support injecting RUNTIME_INIT configuration to RESTEasy Reactive filters ... [quarkus-smallrye-openapi] Support configuring common responses for path and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found