Unable to load Java Property with GraalVM Native Image

I have a simple Maven Project with a single Java class that connects to a DB, runs a Query and outputs the result.

SingleQueryExecutor.java:

public class SingleQueryExecutor {
public static void main(String[] args) throws ClassNotFoundException {
    String url = "jdbc:sqlserver://somehost:1433;DatabaseName=somedb;userName=someuser;password=somepassword;integratedSecurity=true;authenticationScheme=JavaKerberos;loginTimeout=10;socketTimeout=1000;applicationIntent=ReadOnly;sendStringParametersAsUnicode=false;queryTimeout=10;cancelQueryTimeout=5;encrypt=false";

    Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");

    System.out.println("Connecting...");
    try (Connection connection = DriverManager.getConnection(url, user, password);
        Statement statement = connection.createStatement()) {

        System.out.println("Executing query...");
        String query = "SELECT count(*) FROM some_table WHERE some_column='some_value'";
        ResultSet resultSet = statement.executeQuery(query);
        System.out.println("Checking result...");
        if (resultSet.next()) {
            System.out.println("Count: " + resultSet.getInt(1));
        }

        System.exit(0); // Normal termination

    } catch (SQLException e) {
        e.printStackTrace();
        System.exit(1); // Abnormal termination
    }
}

The program requires a Kerberos config file to connect to our DB. I’m able to successfully compile:
javac SingleQueryExecutor.java

and successfully run via:
java -cp mssql-jdbc-12.6.1.jre11.jar:. SingleQueryExecutor

This will pick up my environment variable _JAVA_OPTIONS=-Djava.security.krb5.conf=/opt/kevin/krb5/krb5.conf and successfully run.

But it runs slow so I want to use GraalVM to compile the Program into a Native Image.

I’m using the Graal Maven Plugin to do so. The full native-image command generated from the maven plugin looks like:

/home/runner/.local/graalvm-jdk-17_linux-x64/bin/native-image -cp /home/runner/work/SingleQueryExecutor/target/SingleQueryExecutor-1.0-SNAPSHOT.jar:/home/runner/.m2/repository/com/microsoft/sqlserver/mssql-jdbc/12.6.1.jre11/mssql-jdbc-12.6.1.jre11.jar --no-fallback -H:Path=/home/runner/work/SingleQueryExecutor/target -H:Name=singlequeryexecutor -H:Class=org.example.SingleQueryExecutor -H:DashboardDump=singlequeryexecutor -H:AdditionalSecurityProviders=sun.security.jgss.SunProvider -H:+DashboardAll -Djava.security.krb5.conf=/opt/kevin/krb5/krb5.conf -H:ResourceConfigurationFiles=/home/runner/work/SingleQueryExecutor/src/main/resources/META-INF/native-images/resource-config.json -H:ReflectionConfigurationFiles=/home/runner/work/SingleQueryExecutor/src/main/resources/META-INF/native-images/reflect-config.json

The key piece for this question being -Djava.security.krb5.conf=/opt/kevin/krb5/krb5.conf. Because when I run the binary, it’s ignoring this Java Property and instead just looking at the default krb5.conf file (/etc/krb5/krb5.conf).

I have tried setting the KRB5_CONFIG but no luck.

I have tried include -Djava.security.krb5.conf=/opt/kevin/krb5/krb5.conf when I execute the binary but no luck.

I see there is a <jvmArgs> config possible, but without an example, I wasn’t able to get it to work.

How do I get GraalVM to build a native-image and be able to include Java Properties?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật