Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
fdelbrayelle opened this issue Nov 7, 2019 · 8 comments · Fixed by #5321
Closed
Labels
kind/bug Something isn't working
Milestone

Comments

@fdelbrayelle
Copy link

fdelbrayelle commented Nov 7, 2019

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 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.)

@fdelbrayelle fdelbrayelle added the kind/bug Something isn't working label Nov 7, 2019
@geoand
Copy link
Contributor

geoand commented Nov 7, 2019

@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 geoand closed this as completed Nov 7, 2019
@geoand geoand added the triage/invalid This doesn't seem right label Nov 7, 2019
@fdelbrayelle
Copy link
Author

@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.

@fdelbrayelle
Copy link
Author

As you closed the issue I'm not allowed to re-open it. Feel free to do it if you want :)

@geoand
Copy link
Contributor

geoand commented Nov 8, 2019

I'll reopen and check it out soon

@geoand geoand reopened this Nov 8, 2019
@geoand geoand removed the triage/invalid This doesn't seem right label Nov 8, 2019
@geoand
Copy link
Contributor

geoand commented Nov 8, 2019

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)

@geoand
Copy link
Contributor

geoand commented Nov 8, 2019

Fixed (hopefully :)) by #5321.

@fdelbrayelle
Copy link
Author

Thank you! Why this issue is only with the native image?

@geoand
Copy link
Contributor

geoand commented Nov 8, 2019

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

geoand added a commit that referenced this issue Nov 12, 2019
Ensure that array config values are properly validated at startup
@gsmet gsmet added this to the 1.0.0.Final milestone Nov 15, 2019
ia3andy pushed a commit to dmlloyd/quarkus that referenced this issue Nov 19, 2019
mmusgrov pushed a commit to mmusgrov/quarkus that referenced this issue Dec 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants