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

Config mapping beans not available in a custom Hibernate ConstraintValidator #32265

Closed
ivansenic opened this issue Mar 30, 2023 · 3 comments
Closed
Labels
area/hibernate-validator Hibernate Validator kind/bug Something isn't working

Comments

@ivansenic
Copy link
Contributor

ivansenic commented Mar 30, 2023

Describe the bug

Having a config mapping class:

@ConfigMapping(prefix = "some.props")
public interface MyConfig {
}

I can not inject it into a custom ConstraintValidator using:

@ApplicationScoped
public class MyValidation implements ConstraintValidator<..., ...> {

    @Inject
    MyConfig config;

Exception being thrown:

Caused by: java.util.NoSuchElementException: SRCFG00027: Could not find a mapping for ....MyConfig
	at io.smallrye.config.ConfigMappings.getConfigMapping(ConfigMappings.java:111)
	at io.smallrye.config.SmallRyeConfig.getConfigMapping(SmallRyeConfig.java:411)
	at io.quarkus.arc.runtime.ConfigMappingCreator.create(ConfigMappingCreator.java:31)

Expected behavior

Config mappings can be injected, as they can be injected to other ApplicationScope beans.

Actual behavior

No response

How to Reproduce?

See above.

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.16.4.Final

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

Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63) Maven home: /home/ise/.m2/wrapper/dists/apache-maven-3.8.6-bin/67568434/apache-maven-3.8.6 Java version: 17.0.6, vendor: Private Build, runtime: /usr/lib/jvm/java-17-openjdk-amd64 Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "5.15.0-69-generic", arch: "amd64", family: "unix"

Additional information

Workaround is to use the @ConfigProperty(name = "..") in the validator, which works atm.

@ivansenic ivansenic added the kind/bug Something isn't working label Mar 30, 2023
@quarkus-bot quarkus-bot bot added area/hibernate-orm Hibernate ORM area/persistence OBSOLETE, DO NOT USE labels Mar 30, 2023
@quarkus-bot
Copy link

quarkus-bot bot commented Mar 30, 2023

/cc @Sanne (hibernate-orm), @gsmet (hibernate-orm), @yrodiere (hibernate-orm)

@geoand
Copy link
Contributor

geoand commented Mar 30, 2023

cc @radcortez

@radcortez
Copy link
Member

Duplicated by #24540.

Please use Instance<MyConfig> to inject the mapping.

Closing in favor of #24540.

@yrodiere yrodiere added area/hibernate-validator Hibernate Validator and removed area/persistence OBSOLETE, DO NOT USE area/hibernate-orm Hibernate ORM labels Jun 21, 2023
@yrodiere yrodiere closed this as not planned Won't fix, can't repro, duplicate, stale Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/hibernate-validator Hibernate Validator kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants