Skip to content

Avaje Validator Module : startup error: No configuration setting found for key 'validation' #3610

@thomasguo

Description

@thomasguo

jooby version: 3.5.5
Java: 17
OS: Windows 11

Hello,

I used AvajeInjectModule and AvajeValidatorModule:

    install(AvajeInjectModule.of());
    install(new AvajeValidatorModule());
    
    mvc(PostController.class);
    mvc(UserController.class);

And I didn't do any config work for Avaje Validator. Then when starting the application fatal error occurs. Stack message like following:

Exception in thread "main" io.jooby.exception.StartupException: Application startup resulted in exception
	at io.jooby.Jooby.start(Jooby.java:1003)
	at io.jooby.Jooby.runApp(Jooby.java:1280)
	at io.jooby.Jooby.runApp(Jooby.java:1240)
	at guohai.joobean.app.App.main(App.java:52)
Caused by: com.typesafe.config.ConfigException$Missing: merge of system properties,env variables,application.conf @ file:/D:/lab/joobean/joobean-example/target/classes/application.conf: 1,defaults: No configuration setting found for key 'validation'
	at com.typesafe.config.impl.SimpleConfig.findKeyOrNull(SimpleConfig.java:157)
	at com.typesafe.config.impl.SimpleConfig.findKey(SimpleConfig.java:150)
	at com.typesafe.config.impl.SimpleConfig.findOrNull(SimpleConfig.java:177)
	at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:189)
	at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:194)
	at com.typesafe.config.impl.SimpleConfig.getString(SimpleConfig.java:251)
	at io.jooby.avaje.inject.JoobyPropertyPlugin.get(JoobyPropertyPlugin.java:27)
	at io.avaje.validation.inject.spi.DefaultValidatorProvider.lambda$validator$4(DefaultValidatorProvider.java:61)
	at io.avaje.inject.spi.DContextEntryBean$OnceProvider.bean(DContextEntryBean.java:160)
	at io.avaje.inject.spi.DContextEntry$EntryMatcher.checkSecondary(DContextEntry.java:214)
	at io.avaje.inject.spi.DContextEntry$EntryMatcher.candidate(DContextEntry.java:208)
	at io.avaje.inject.spi.DContextEntry$EntryMatcher.findMatch(DContextEntry.java:144)
	at io.avaje.inject.spi.DContextEntry$EntryMatcher.match(DContextEntry.java:120)
	at io.avaje.inject.spi.DContextEntry.get(DContextEntry.java:53)
	at io.avaje.inject.spi.DBeanMap.get(DBeanMap.java:121)
	at io.avaje.inject.spi.DBuilder.getMaybe(DBuilder.java:141)
	at io.avaje.inject.spi.DBuilder.getBean(DBuilder.java:384)
	at io.avaje.inject.spi.DBuilder.get(DBuilder.java:333)
        ...

I did some debug and in the class io.jooby.avaje.inject.JoobyPropertyPlugin like below:

    @Override
    public Optional<String> get(String property) {
        return config.hasPath(property)
                ? Optional.empty()
                : Optional.ofNullable(config.getString(property));
    }

IMO maybe it should be something like this ?

        return config.hasPath(property)
                ? Optional.ofNullable(config.getString(property))
                : Optional.empty();

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions