1

I have a problem with Helidon 2.0.1

When I try to use external file /etc/config/application.yaml using ConfigFile, JPA does not work. The port-config(serve.port: 8001) it works.

The good news is When I use internal config file it works very well, using "src/main/resources/application.yaml"

My custom Start Server:

    static Server startServer() {
        return Server.builder() 
                .config(buildConfig()) 
                .build() 
                .start();
    }

    public static Config buildConfig() {
        return Config.builder().sources( 
                ConfigSources.file("/etc/conf/application.yaml")
        ).build();
    }

My persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.2"
    xmlns="http://xmlns.jcp.org/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
                                 http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd">
    <persistence-unit name="ZettaPU"
        transaction-type="JTA">
        <description>A persistence unit for the Zetta.</description>
        <jta-data-source>ZettaDS</jta-data-source>
        <class>com.zetta.entities.Catalogo</class>
        <properties>
            <property name="eclipselink.deploy-on-startup" value="true" />
            <property name="eclipselink.jdbc.native-sql" value="true" />
            <property name="eclipselink.logging.logger" value="JavaLogger" />
            <property name="eclipselink.logging.parameters" value="true" />
            <property name="eclipselink.target-database" value="org.eclipse.persistence.platform.database.SQLServerPlatform" />
            <property name="eclipselink.target-server" value="io.helidon.integrations.cdi.eclipselink.CDISEPlatform" />
            <property name="eclipselink.weaving" value="false" />
        </properties>
    </persistence-unit>
</persistence>

My application.yaml

server:
    port: 8001
    host: 0.0.0.0
javax:
    sql:
        DataSource: 
            distribuidoresDS: 
                dataSourceClassName: com.microsoft.sqlserver.jdbc.SQLServerDataSource
                dataSource: 
                    url: jdbc:sqlserver://localhost:1433;databaseName=ZettaDB; 
                    user: zettaDB
                    password: ********

Thanks a lot

Laird Nelson
  • 15,321
  • 19
  • 73
  • 127
JE Zamora
  • 146
  • 8

1 Answers1

0

As explained at https://helidon.io/docs/latest/#/mp/guides/03_config I suggest you to give a try to this solution:

  private static Config buildConfig() {
    return Config.builder()
        .disableEnvironmentVariablesSource() 
        .sources(
            file("/etc/conf/application.yaml"),
            classpath("application.yaml"), 
            classpath("META-INF/microprofile-config.properties")) 
        .build();
  }

PS: the order is important to get internal configuration overrided by the external.

Antonio Petricca
  • 8,891
  • 5
  • 36
  • 74