javafxgraalvmgluongraalvm-native-imagegluonfx

Gluonhq with JDBC SQLite : ClassNotFoundException: org.graalvm.nativeimage.hosted.RuntimeRe


I am using Gluonhq with JDBC in Linux.

Version info: 'GraalVM 22.1.0.1 Java 17 CE'

There are no problems with postgresql. The problems begin when I work with sqlite.

My JDBC connect:

Connection connection = DriverManager.getConnection(
    "jdbc:sqlite:/home/alex/IdeaProjects/db/base/materials.db"
);

I do

mvn clean gluonfx:runagent

Everything works correctly, the data from sqlite database is read.

Then I do

mvn clean gluonfx:build

I got

java.lang.NoClassDefFoundError: org/graalvm/nativeimage/hosted/RuntimeResourceAccess org.sqlite.nativeimage.SqliteJdbcFeature.handleLibraryResources(SqliteJdbcFeature.java:54) Caused by: java.lang.ClassNotFoundException: org.graalvm.nativeimage.hosted.RuntimeResourceAccess

Here you can view the entire maven log

I added

<nativeImageArgs>
<arg>-Dorg.sqlite.lib.exportPath=/home/alex/IdeaProjects/</arg>
</nativeImageArgs>

And got new error

java.lang.NoClassDefFoundError: org/graalvm/nativeimage/hosted/RuntimeJNIAccess org.sqlite.nativeimage.SqliteJdbcFeature.registerJNICalls(SqliteJdbcFeature.java:70 Caused by: java.lang.ClassNotFoundException: org.graalvm.nativeimage.hosted.RuntimeJNIAccess

Row 70 of SqliteJdbcFeature.java: RuntimeJNIAccess.register(NativeDB.class);

I checked jni-config.json

{
  "name":"org.sqlite.core.DB",
  "methods":[
    {"name":"onCommit","parameterTypes":["boolean"] }, 
    {"name":"onUpdate","parameterTypes":["int","java.lang.String","java.lang.String","long"] }, 
    {"name":"throwex","parameterTypes":[] }, 
    {"name":"throwex","parameterTypes":["int"] }
  ]
},
{
  "name":"org.sqlite.core.DB$ProgressObserver",
  "methods":[{"name":"progress","parameterTypes":["int","int"] }]
},
{
  "name":"org.sqlite.core.NativeDB",
  "fields":[
    {"name":"busyHandler"}, 
    {"name":"commitListener"}, 
    {"name":"pointer"}, 
    {"name":"progressHandler"}, 
    {"name":"updateListener"}
  ],
  "methods":[
    {"name":"stringToUtf8ByteArray","parameterTypes":["java.lang.String"] }, 
    {"name":"throwex","parameterTypes":["java.lang.String"] }
  ]
}, ...

Here my pom

Help!!


Solution

  • I recolved my problem by replacing dependecy

        <dependency>
            <groupId>org.xerial</groupId>
            <artifactId>sqlite-jdbc</artifactId>
            <version>3.42.0.0</version>
        </dependency>
    

    witch

    <dependency>
        <groupId>io.github.willena</groupId>
        <artifactId>sqlite-jdbc</artifactId>
        <version>3.35.5.3</version>
    </dependency>