Meta Config not working
See original GitHub issueEnvironment Details
- Helidon Version: 2.2.2
- Helidon MP
- JDK version: 11
- OS: Linux Mint (Ubuntu 18.04)
- Docker version (if applicable): not applicable
Problem Description
I am trying to define custom configuration sources by the meta-config.yaml
file.
The web server starts, but the configuration is not applied. To be sure I moved the application.yaml
file from the root classpath to the META-INF
folder, but I get the exception you can see in the attached log about the HikariCP datasource configuration.
If I restore the application.yaml
file location, despite of the meta-config.yaml
file, Helidon loads the root application.yaml
configuration.
Then I tried to abort the usage of meta config, and I added the sources directly to the config builder, but the result is the same.
In summary, the custom configuration is never used.
Thank you so much in advance!
Steps to reproduce
Here is my relevant code:
META-INF/meta-config.yaml
sources:
- type: "environment-variables"
- type: "system-properties"
- type: "classpath"
properties:
resource: "META-INF/microprofile-config.properties"
- type: "classpath"
properties:
resource: "META-INF/application.yaml"
#TODO Some other sources...
META-INF/application.yaml
server:
port: ${server.port.api}
javax:
sql:
DataSource:
defaultDS:
poolName: "${jpa.pool.name}"
driverClassName: ${jpa.driver}
jdbcUrl: ${jpa.url}
maximumPoolSize: ${jpa.pool.max}
minimumIdle: ${jpa.pool.min}
idleTimeout: ${jpa.pool.min.idle}
dataSource:
user: ${jpa.user}
password: ${jpa.password}
ApplicationMain.java
import io.helidon.config.Config;
import io.helidon.microprofile.server.Server;
public final class ApplicationMain {
private static Config buildConfig() {
return Config
.builder()
.metaConfig()
.addSource(classpath("META-INF/meta-config.yaml"))
.build();
}
public static void main(final String[] args) {
Server
.builder()
.config(buildConfig())
.build()
.start();
}
}
Log fragment
[2021-05-13 14:37:42,373] [INFO ] [i.h.m.cdi.HelidonContainerImpl$HelidonCdi.close:391] WELD-ENV-002001: Weld SE container b13c25c8-10c7-47ef-911b-0f08e8bc1474 shut down Exception in thread “main” org.jboss.weld.exceptions.UnsatisfiedResolutionException: WELD-001334: Unsatisfied dependencies for type DataSource with qualifiers @Default @Named at org.jboss.weld.bean.builtin.InstanceImpl.checkBeanResolved(InstanceImpl.java:241) at org.jboss.weld.bean.builtin.InstanceImpl.get(InstanceImpl.java:113) at io.helidon.integrations.cdi.jpa.JtaDataSourceProvider.getDataSource(JtaDataSourceProvider.java:223) at io.helidon.integrations.cdi.jpa.JtaDataSourceProvider$Proxy$_$$WeldClientProxy.getDataSource(Unknown Source) at io.helidon.integrations.cdi.jpa.PersistenceUnitInfoBean.getJtaDataSource(PersistenceUnitInfoBean.java:714) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.jboss.weld.bean.proxy.AbstractBeanInstance.invoke(AbstractBeanInstance.java:38) at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:106) at org.jboss.weldx.persistence.spi.PersistenceUnitInfo$$Proxy$$$WeldClientProxy.getJtaDataSource(Unknown Source) at org.hibernate.jpa.boot.internal.PersistenceUnitInfoDescriptor.getJtaDataSource(PersistenceUnitInfoDescriptor.java:48) at org.hibernate.jpa.internal.util.LogHelper.logPersistenceUnitInformation(LogHelper.java:50) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:191) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:168) at org.hibernate.jpa.boot.spi.Bootstrap.getEntityManagerFactoryBuilder(Bootstrap.java:32) at org.hibernate.jpa.boot.spi.Bootstrap.getEntityManagerFactoryBuilder(Bootstrap.java:89) at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilder(HibernatePersistenceProvider.java:166) at org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:141) at org.hibernate.jpa.HibernatePersistenceProvider$Proxy$$$WeldClientProxy.createContainerEntityManagerFactory(Unknown Source) at io.helidon.integrations.cdi.jpa.EntityManagerFactories.createContainerManagedEntityManagerFactory(EntityManagerFactories.java:189) at io.helidon.integrations.cdi.jpa.JpaExtension.lambda$addContainerManagedEntityManagerFactoryBeans$1(JpaExtension.java:1102) at org.jboss.weld.bootstrap.events.configurator.BeanConfiguratorImpl$CreateCallback.create(BeanConfiguratorImpl.java:368) at org.jboss.weld.bootstrap.events.configurator.BeanConfiguratorImpl$CreateCallback.access$700(BeanConfiguratorImpl.java:338) at org.jboss.weld.bootstrap.events.configurator.BeanConfiguratorImpl$ImmutableBean.create(BeanConfiguratorImpl.java:503) at org.jboss.weld.contexts.AbstractContext.get(AbstractContext.java:96) at org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.get(ContextualInstanceStrategy.java:100) at org.jboss.weld.bean.ContextualInstance.get(ContextualInstance.java:50) at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:102) at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:105) at org.jboss.weldx.persistence.EntityManagerFactory$$Proxy$$$WeldClientProxy.createEntityManager(Unknown Source) at io.helidon.integrations.cdi.jpa.EntityManagers.createContainerManagedEntityManager(EntityManagers.java:144) at io.helidon.integrations.cdi.jpa.EntityManagers.createContainerManagedEntityManager(EntityManagers.java:75) at io.helidon.integrations.cdi.jpa.NonTransactionalEntityManager.<init>(NonTransactionalEntityManager.java:87) at io.helidon.integrations.cdi.jpa.JpaExtension.lambda$addNonTransactionalEntityManagerBeans$6(JpaExtension.java:1285) at org.jboss.weld.bootstrap.events.configurator.BeanConfiguratorImpl$CreateCallback.create(BeanConfiguratorImpl.java:368) at org.jboss.weld.bootstrap.events.configurator.BeanConfiguratorImpl$CreateCallback.access$700(BeanConfiguratorImpl.java:338) at org.jboss.weld.bootstrap.events.configurator.BeanConfiguratorImpl$ImmutableBean.create(BeanConfiguratorImpl.java:503) at io.helidon.integrations.cdi.referencecountedcontext.ReferenceCountedContext$Instance.<init>(ReferenceCountedContext.java:472) at io.helidon.integrations.cdi.referencecountedcontext.ReferenceCountedContext.get(ReferenceCountedContext.java:304) at io.helidon.integrations.cdi.referencecountedcontext.ReferenceCountedContext.get(ReferenceCountedContext.java:260) at org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.get(ContextualInstanceStrategy.java:100) at org.jboss.weld.bean.ContextualInstance.get(ContextualInstance.java:50) at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:102) at org.jboss.weld.bean.proxy.ProxyMethodHandler.getInstance(ProxyMethodHandler.java:131) at io.helidon.integrations.cdi.jpa.NonTransactionalEntityManager$Proxy$$$_WeldClientProxy.clear(Unknown Source) at io.helidon.integrations.cdi.jpa.DelegatingEntityManager.clear(DelegatingEntityManager.java:263) at io.helidon.integrations.cdi.jpa.JpaTransactionScopedEntityManager.clear(JpaTransactionScopedEntityManager.java:512) at it.sisal.betting.api.demo.common.persistence.HibernateInitializer.onInitialize(HibernateInitializer.java:27) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:95) at org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:85) at org.jboss.weld.injection.MethodInvocationStrategy$SimpleMethodInvocationStrategy.invoke(MethodInvocationStrategy.java:168) at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:330) at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:308) at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:286) at javax.enterprise.inject.spi.ObserverMethod.notify(ObserverMethod.java:124) at org.jboss.weld.util.Observers.notify(Observers.java:166) at org.jboss.weld.event.ObserverNotifier.notifySyncObservers(ObserverNotifier.java:285) at org.jboss.weld.event.ObserverNotifier.notify(ObserverNotifier.java:273) at org.jboss.weld.event.EventImpl.fire(EventImpl.java:96) at io.helidon.microprofile.cdi.HelidonContainerImpl.doStart(HelidonContainerImpl.java:339) at io.helidon.common.context.Contexts.runInContext(Contexts.java:137) at io.helidon.microprofile.cdi.HelidonContainerImpl.start(HelidonContainerImpl.java:249) at io.helidon.microprofile.server.ServerImpl.start(ServerImpl.java:85) at ApplicationMain.main(ApplicationMain.java:33)
Process finished with exit code 1
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
quickstart-mp-config.zip
@antonio-petricca After a closer look at your code, I think there’s just a mix between config and meta-config. Still not sure why moving your
meta-config.yaml
made a difference, would need to investigate that.In any case, it’s a lot easier if you just use the property
io.helidon.config.meta-config
to point to your meta configuration. I’m attaching a sample project that uses your meta config file to find properties. Hope it helps.