Unable to load the config property type: [Ljava.lang.String through native image
See original GitHub issueThe 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<String> solve the problem.
Any idea why it is not working through the native image running?
Steps to reproduce the behavior:
- Set a config property to a list of String such as “partners.available=ABC,DEF”
- Get it from @ConfigProperty into a String[].
- Build the native image with such a command :
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
- Launch the native image with :
./target/application.runner
Environment :
- Output of
uname -r
: 5.0.0-32-generic - Output of
java -version
: openjdk version “1.8.0_222” - GraalVM version (if different from Java): 19.2.1
- Quarkus version or git rev: 0.25.0
Additional context (Add any other context about the problem here.)
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
First React Native App: Task :app:processDebugMainManifest ...
What worked for me on JDK 17, and should for JDK 16 too: Append the following line to the ./android/gradle.properties file in your...
Read more >Native Image Compatibility and Optimization Guide - GraalVM
If the native image building cis unable to optimize an application, it generates a so-called “fallback file” that requires a Java VM to...
Read more >Tips for writing native applications - Quarkus
To include more resources in the native executable, the easiest way is to use the quarkus.native.resources.includes configuration property, ...
Read more >Spring Boot Maven Plugin Documentation
Type. java.lang.String. Default value. User property. spring-boot. ... OCI image from a jar or war file using Cloud Native Buildpacks (CNB).
Read more >Configuring your Quarkus applications by using a properties file
In Quarkus 2.7, building native executables by using Java 17 is provided as a ... Failed to load config value of type class...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It’s because Class.forName needs to have reflection enabled on the “target” class for it to work in native mode.
Fixed (hopefully 😃) by #5321.