question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to load the config property type: [Ljava.lang.String through native image

See original GitHub issue

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<String> solve the problem.

Any idea why it is not working through the native image running?

Steps to reproduce the behavior:

  1. Set a config property to a list of String such as “partners.available=ABC,DEF”
  2. Get it from @ConfigProperty into a String[].
  3. 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
  4. 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:closed
  • Created 4 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
geoandcommented, Nov 8, 2019

It’s because Class.forName needs to have reflection enabled on the “target” class for it to work in native mode.

1reaction
geoandcommented, Nov 8, 2019

Fixed (hopefully 😃) by #5321.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found