0

I have a maven multi module project using quarkus. The architecturecan be simplified like this:

**module1 **-> configuration file such as application.properties

---src
------main
---------resources
------------application.properties
------------application-devlocal.properties

**module2 **-> entities + MyCustomConfigSource

---src
------main
---------java
------------MyEntity1.java
------------MyCustomConfigSource.java
---------resources
------------META-INF
---------------services
------------------org.eclipse.microprofile.config.spi.ConfigSource

**module3 **-> first quarkus module **module4 **-> second quarkus module

The goal of my custom config source is to get properties from a database table and if the property is not in the database then take it from application.properties. But when I launch the quarkus module4 in dev mode, it seems that the config source is not registered. As I have the following error:

The config property MyPropertyFromDB is required but it could not be found in any config source.

The application is able to read properties from application.properties.Moreover if I inject my MyCustomConfigSource in another bean, I am able to see all properties stored in by database (by calling the method getProperties of the config source). So it is not a connection issue.

Here is the content of my custom config source MyCustomConfigSource.

@ApplicationScope
@Transactional
public class MyCustomConfigSource implements ConfigSource
{

    @Inject
    private EntityManager entityManager;
    private Config config;

    @Override
    public int getOrdinal()
    { 
        return 500;
    }

    @Override
    public Set<String> getPropertyNames() {
       //...
    }

    @Override
    public Map<String, String> getProperties() {
        //...
    }

    @Override
    public String getValue(String key) {
        //...
    }

    @Override
    public String getName() {
        //...
    }

}

I am using quarkus 3.0.0.Alpha4 and JDK 11.

Moreover, during my tests, I see that if I add the annotation @io.quarkus.runtime.Startup then I am able to access the properties store in my database but quarkus is not able to access custom properties from application.properties anymore.

okyn29
  • 11
  • 4
  • Does it work with latest stable? – Luca Basso Ricci Feb 21 '23 at 15:25
  • The project was a wildfly project that I am currently migrating to quarkus. As there are a lot of difference between 2.X and 3.X and the migration is not over I can't rollback to an oldest version of quarkus. I already spent a lot of time to reach the current state and I would prefer not to downgrade to 2.X. – okyn29 Feb 21 '23 at 15:32
  • https://quarkus.io/guides/config-mappings#static-init can help? – Luca Basso Ricci Feb 28 '23 at 10:32

1 Answers1

0

Unable to do it directly with microprofile but I succeed to do it with the extension quarkus-config-extensions (https://github.com/quarkiverse/quarkus-config-extensions)

See https://github.com/quarkusio/quarkus/issues/31327

okyn29
  • 11
  • 4