Quarkus: Refesh brower try to hot reload changes of properties, but throws `javax.enterprise.inject.spi.DeploymentException`

Created on 15 Sep 2019  路  4Comments  路  Source: quarkusio/quarkus

Describe the bug
I'am not sure is that a bug, but I just try to learn Quarkus and followed Custom Configuration that official doc.
Begin it's all ok, but soon I want to try whether quarkus could hot reload properties with custom configuration converter. So I first make the target type MicroProfileCustomValue not be final and with a setter.

public class MicroProfileCustomValue {
    private int number;

    public MicroProfileCustomValue(int number) {
        this.number = number;
    };

    public int getNumber() {
        return number;
    }

    public void setNumber(int number) {
        this.number = number;
    }
}

then, I kept the custom converter same with offcial doc, and also created the org.eclipse.microprofile.config.spi.Converter file too.

public class MicroProfileCustomValueConverter implements Converter<MicroProfileCustomValue> {
    @Override
    public MicroProfileCustomValue convert(String value) {
        return new MicroProfileCustomValue(Integer.parseInt(value));
    }
}

the file ....../src/main/resources/META-INF/services/org.eclipse.microprofile.config.spi.Converter contents include only one line.

com.catherine.config.MicroProfileCustomValueConverter

And in the GreetingResource.java file which contains by starter-project, I add this property inject.

    @ConfigProperty(name = "configuration.value.name")
    MicroProfileCustomValue value;

finally, I add the property configuration.value.name into applicaiotn.properties.

configuration.value.name = 1

I write a simple Get method in the GreetingResource.java file, and for convinent only return the value of that field. Then I start the quakurs with quarkus:dev -Ddebug, and no doubt, the result print on browser is 1 and work very well.

But problem show up when I changed the property, I just change the value to 2......

configuration.value.name = 2

after save, and refresh the browser, the exception like below just throws out......

java.lang.RuntimeException: Failed to start quarkus
    at io.quarkus.runner.ApplicationImpl2.doStart(ApplicationImpl2.zig:213)
    at io.quarkus.runtime.Application.start(Application.java:91)
    at io.quarkus.runner.RuntimeRunner.run(RuntimeRunner.java:127)
    at io.quarkus.dev.DevModeMain.doStart(DevModeMain.java:180)
    at io.quarkus.dev.DevModeMain.restartApp(DevModeMain.java:195)
    at io.quarkus.dev.RuntimeUpdatesProcessor.doScan(RuntimeUpdatesProcessor.java:116)
    at io.quarkus.undertow.deployment.devmode.UndertowHotReplacementSetup.handleHotDeploymentRequest(UndertowHotReplacementSetup.java:72)
    at io.quarkus.undertow.deployment.devmode.UndertowHotReplacementSetup$1$1.handleRequest(UndertowHotReplacementSetup.java:61)
    at io.undertow.server.Connectors.executeRootHandler(Connectors.java:376)
    at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:830)
    at io.quarkus.runtime.CleanableExecutor$CleaningRunnable.run(CleanableExecutor.java:224)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
    at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2011)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1535)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1426)
    at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
    at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
    at java.lang.Thread.run(Thread.java:748)
    at org.jboss.threads.JBossThread.run(JBossThread.java:479)
Caused by: javax.enterprise.inject.spi.DeploymentException: java.lang.IllegalArgumentException: No Converter registered for class class com.catherine.config.MicroProfileCustomValue
    at io.quarkus.arc.runtime.ConfigRecorder.validateConfigProperties(ConfigRecorder.java:40)
    at io.quarkus.deployment.steps.ConfigBuildStep$validateConfigProperties27.deploy_0(ConfigBuildStep$validateConfigProperties27.zig:154)
    at io.quarkus.deployment.steps.ConfigBuildStep$validateConfigProperties27.deploy(ConfigBuildStep$validateConfigProperties27.zig:36)
    at io.quarkus.runner.ApplicationImpl2.doStart(ApplicationImpl2.zig:177)
    ... 20 more
Caused by: java.lang.IllegalArgumentException: No Converter registered for class class com.catherine.config.MicroProfileCustomValue
    at io.smallrye.config.SmallRyeConfig.getConverter(SmallRyeConfig.java:152)
    at io.smallrye.config.SmallRyeConfig.convert(SmallRyeConfig.java:132)
    at io.smallrye.config.SmallRyeConfig.getOptionalValue(SmallRyeConfig.java:98)
    at io.quarkus.arc.runtime.ConfigRecorder.validateConfigProperties(ConfigRecorder.java:35)
    ... 23 more

So... should I do something wrong and didn't match the condition of hot reload? or is just some bad manner on ServiceLoader? I'am not familiar with that....

Environment:

  • Output of uname -a or ver: Darwin Mac-mini 18.7.0 Darwin Kernel Version 18.7.0
  • Output of java -version:
java version "1.8.0_221"
Java(TM) SE Runtime Environment (build 1.8.0_221-b11)
Java HotSpot(TM) 64-Bit GraalVM EE 19.2.0 (build 25.221-b11-jvmci-19.2-b02, mixed mode)
  • GraalVM version (if different from Java):
    same above.

  • Quarkus version or git rev: quarkus 0.21.2

  • Intellij IDEA 2019.2.2
areconfig aredevmode kinbug triagout-of-date

Most helpful comment

Dev mode has its own "version" of a lot of the bootup path, and I think part of it is going to relate to config setup. There's probably an easy-ish fix in the dev mode setup code, but the "right" fix IMO is to try and unify dev mode startup with "real" startup as much as possible, to try and reduce the number of dev-mode-specific bugs that we have.

All 4 comments

@dmlloyd this one looks like a config issue?

Dev mode has its own "version" of a lot of the bootup path, and I think part of it is going to relate to config setup. There's probably an easy-ish fix in the dev mode setup code, but the "right" fix IMO is to try and unify dev mode startup with "real" startup as much as possible, to try and reduce the number of dev-mode-specific bugs that we have.

Dev mode has its own "version" of a lot of the bootup path, and I think part of it is going to relate to config setup. There's probably an easy-ish fix in the dev mode setup code, but the "right" fix IMO is to try and unify dev mode startup with "real" startup as much as possible, to try and reduce the number of dev-mode-specific bugs that we have.

totally agree, and thanks for your response~~

Just tested and this works now.

Was this page helpful?
0 / 5 - 0 ratings