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

Smallrye ConfigSourceFactory not loading class #21703

Closed
andrerigon opened this issue Nov 25, 2021 · 7 comments · Fixed by #21887
Closed

Smallrye ConfigSourceFactory not loading class #21703

andrerigon opened this issue Nov 25, 2021 · 7 comments · Fixed by #21887
Assignees
Labels
area/config kind/bug Something isn't working
Milestone

Comments

@andrerigon
Copy link
Contributor

andrerigon commented Nov 25, 2021

Describe the bug

When using a ConfigSourceFactory the class is not loaded and the build (both maven and gradle) fails with:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.737 s
[INFO] Finished at: 2021-11-25T11:24:15-03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.quarkus.platform:quarkus-maven-plugin:2.5.0.Final:generate-code (default) on project bidder: Quarkus code generation phase has failed: InvocationTargetException: io.smallrye.config.ConfigSourceFactory: Provider com.adquick.service.athena.ConsumerConfig not found -> [Help 1]

Goals tested: quarkus:dev, compile, package.
The class referenced in the src/main/resources/META-INF/services/io.smallrye.config.ConfigSourceFactory file is being loaded before its compilation.
Works when using Quarkus 1.13.4.

Expected behavior

The config factory should be loaded and executed.

Actual behavior

Buidl failes with:

Caused by: java.util.ServiceConfigurationError: io.smallrye.config.ConfigSourceFactory: Provider com.adquick.service.athena.ConsumerConfig not found
    at java.util.ServiceLoader.fail (ServiceLoader.java:593)
    at java.util.ServiceLoader$LazyClassPathLookupIterator.nextProviderClass (ServiceLoader.java:1219)
    at java.util.ServiceLoader$LazyClassPathLookupIterator.hasNextService (ServiceLoader.java:1228)
    at java.util.ServiceLoader$LazyClassPathLookupIterator.hasNext (ServiceLoader.java:1273)
    at java.util.ServiceLoader$2.hasNext (ServiceLoader.java:1309)
    at java.util.ServiceLoader$3.hasNext (ServiceLoader.java:1393)

How to Reproduce?

Run quarkus:dev to reproduce:

./mvnw clean compile quarkus:dev

A "workaround":

  1. Comment the class in:
src/main/resources/META-INF/services/io.smallrye.config.ConfigSourceFactory
  1. Run ./mvnw compile

  2. Uncomment the class

  3. Run:

./mvnw quarkus:dev

bidder-maven.zip

Output of uname -a or ver

Darwin Andre-MacBook-Pro.local 20.6.0 Darwin Kernel Version 20.6.0: Mon Aug 30 06:12:21 PDT 2021; root:xnu-7195.141.6~3/RELEASE_X86_64 x86_64

Output of java -version

openjdk version "17.0.1" 2021-10-19 OpenJDK Runtime Environment GraalVM CE 21.3.0 (build 17.0.1+12-jvmci-21.3-b05) OpenJDK 64-Bit Server VM GraalVM CE 21.3.0 (build 17.0.1+12-jvmci-21.3-b05, mixed mode, sharing)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.5.0.Final

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

Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)

Additional information

No response

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

quarkus-bot bot commented Nov 25, 2021

@gastaldi
Copy link
Contributor

Seems to be an issue in the generate code mojo (egg/chicken problem?).
Adding -Dquarkus.generate-code.skip to the ./mvnw compile avoids the need to comment the class in src/main/resources/META-INF/services/io.smallrye.config.ConfigSourceFactory

@andrerigon
Copy link
Contributor Author

Yes, but then the code doesn't compile - we use quarkus-avro.

@gastaldi
Copy link
Contributor

Sure, not saying it's the solution, just something I observed while running the steps to reproduce it 😉

@radcortez
Copy link
Member

Caused by #20819 and

final SmallRyeConfig config = ConfigUtils.configBuilder(false, launchMode)
.withProfile(launchMode.getDefaultProfile())
.withSources(pcs)
.build();

@michalszynkiewicz can we disable discover sources for this Config instance? I believe no one is expecting to have their sources contributing config here.

@radcortez
Copy link
Member

Or if it is really required, any configuration component that requires compilation needs to be into a separate module.

@michalszynkiewicz
Copy link
Member

@radcortez if I understand the quesiton correctly, then the answer is yes.
Having properties from application.properties/yaml should be enough for code gen IMO

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/config kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants