The application is running in error when launching a native image of an application getting a config property as a String[] :
./target/services-matching-quarkus-1.0.0-SNAPSHOT-runner
java.lang.IllegalStateException: Unable to load the config property type: [Ljava.lang.String;
at io.quarkus.arc.runtime.ConfigRecorder.load(ConfigRecorder.java:70)
at io.quarkus.arc.runtime.ConfigRecorder.validateConfigProperties(ConfigRecorder.java:29)
at io.quarkus.deployment.steps.ConfigBuildStep$validateConfigProperties24.deploy_0(ConfigBuildStep$validateConfigProperties24.zig:188)
at io.quarkus.deployment.steps.ConfigBuildStep$validateConfigProperties24.deploy(ConfigBuildStep$validateConfigProperties24.zig:36)
at io.quarkus.runner.ApplicationImpl1.doStart(ApplicationImpl1.zig:210)
at io.quarkus.runtime.Application.start(Application.java:94)
at io.quarkus.runtime.Application.run(Application.java:218)
at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:41)
2019-11-07 08:21:06,531 WARN [io.qua.arc] (main) An error occured during delivery of the @BeforeDestroyed(ApplicationScoped.class) event: java.lang.NullPointerException
at io.quarkus.mongodb.runtime.MongoClientProducer.onStop(MongoClientProducer.java:20)
at io.quarkus.mongodb.runtime.MongoClientProducer_Observer_onStop_6e82549763245071a3987b5e25ba17616004a313.notify(MongoClientProducer_Observer_onStop_6e82549763245071a3987b5e25ba17616004a313.zig:53)
at io.quarkus.arc.EventImpl$Notifier.notify(EventImpl.java:228)
at io.quarkus.arc.EventImpl$Notifier.notify(EventImpl.java:218)
at io.quarkus.arc.ArcContainerImpl.shutdown(ArcContainerImpl.java:275)
at io.quarkus.arc.Arc.shutdown(Arc.java:37)
at io.quarkus.arc.runtime.ArcRecorder$1.run(ArcRecorder.java:37)
at io.quarkus.runtime.StartupContext.close(StartupContext.java:43)
at io.quarkus.runner.ApplicationImpl1.doStart(ApplicationImpl1.zig:276)
at io.quarkus.runtime.Application.start(Application.java:94)
at io.quarkus.runtime.Application.run(Application.java:218)
at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:41)
2019-11-07 08:21:06,535 INFO [io.sma.rea.mes.ext.MediatorManager] (main) Cancel subscriptions
Exception in thread "main" java.lang.RuntimeException: Failed to start quarkus
at io.quarkus.runner.ApplicationImpl1.doStart(ApplicationImpl1.zig:282)
at io.quarkus.runtime.Application.start(Application.java:94)
at io.quarkus.runtime.Application.run(Application.java:218)
at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:41)
Caused by: java.lang.IllegalStateException: Unable to load the config property type: [Ljava.lang.String;
at io.quarkus.arc.runtime.ConfigRecorder.load(ConfigRecorder.java:70)
at io.quarkus.arc.runtime.ConfigRecorder.validateConfigProperties(ConfigRecorder.java:29)
at io.quarkus.deployment.steps.ConfigBuildStep$validateConfigProperties24.deploy_0(ConfigBuildStep$validateConfigProperties24.zig:188)
at io.quarkus.deployment.steps.ConfigBuildStep$validateConfigProperties24.deploy(ConfigBuildStep$validateConfigProperties24.zig:36)
at io.quarkus.runner.ApplicationImpl1.doStart(ApplicationImpl1.zig:210)
... 3 more
This bug is not reproduced when launching the application without the native image with mvn clean compile quarkus:dev.
application.properties :
partners.available=ABC,DEF
PartnerService.java :
package org.acme.quickstart;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import javax.enterprise.context.ApplicationScoped;
import java.util.stream.Stream;
@ApplicationScoped
public class PartnerService {
@ConfigProperty(name="partners.available")
private String[] availablePartners;
public Stream<String> findByService() {
return Stream.of(availablePartners);
}
}
Updating the availablePartners from String[] to List
Any idea why it is not working through the native image running?
Steps to reproduce the behavior:
docker run -v $PWD:/sources --workdir=/sources -v $HOME/.m2/repository:/home/quarkus/.m2/repository -it centos-quarkus-maven:19.2.1 mvn -Pnative package
./target/application.runnerEnvironment :
uname -r: 5.0.0-32-genericjava -version: openjdk version "1.8.0_222"Additional context
(Add any other context about the problem here.)
@fdelbrayelle you are using a fairly old (in the supersonic Quarkus sense :)).
I tried this this with the latest Quarkus version and couldn't reproduce it and therefore I'm going to close this.
Feel free to reopen with more information if you try the latest version and find the problem again and can provide more info.
Thanks
@geoand In fact I've made a typo in the original issue. The code to reproduce it is:
@ConfigProperty(name="partners.available")
private String[] availablePartners;
public Stream<String> findByService() {
return Stream.of(availablePartners);
}
And not:
@ConfigProperty(name="partners.available")
private List<String> availablePartners;
public Stream<String> findByService() {
return availablePartners.stream();
}
Reproduced in version 1.0.0.CR1 as well.
As you closed the issue I'm not allowed to re-open it. Feel free to do it if you want :)
I'll reopen and check it out soon
I think I know what the issue is just by looking at the array, but I'm traveling so won't be able to fix for a few hours (or maybe over the weekend)
Fixed (hopefully :)) by #5321.
Thank you! Why this issue is only with the native image?
It's because Class.forName needs to have reflection enabled on the "target" class for it to work in native mode.