javasqldatabasejackcess

JackCess "NoClassDefFoundError: java/sql/Blob" exception


The following simple java program:

import com.healthmarketscience.jackcess.util.OleBlob;

public class Test {

    public static void main(String[] args) throws Exception {
        byte[] data = new byte[100];
        OleBlob oleBlob = OleBlob.Builder.fromInternalData(data);
    }
}

gets me the exception

Exception in thread "main" java.lang.NoClassDefFoundError: java/sql/Blob
    at java.base/java.lang.ClassLoader.defineClass1(Native Method)
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1010)
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1088)
    at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:182)
    at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:814)
    at java.base/jdk.internal.loader.BuiltinClassLoader.findClassInModuleOrNull(BuiltinClassLoader.java:735)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:660)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:634)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:182)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:519)
    at com.healthmarketscience.jackcess@4.0.1/com.healthmarketscience.jackcess.util.OleBlob$Builder.fromInternalData(OleBlob.java:423)
    at tabellenFahrplan/test.Test.main(Test.java:12)
Caused by: java.lang.ClassNotFoundException: java.sql.Blob
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:636)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:182)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:519)
    ... 12 more

JackCess documentation says in case of such an exception there are dependencies missing. But what dependendy referring to java/sql/Blob which is part of Java already? Besides, through maven I already have the dependencies

running JackCess 4.0.1 on OpenJdk 16.0.2


Solution

  • The problem was I was missing entries in the module-info.java file. Regarding my initial question it is

    requires java.sql;
    

    Going along using JackCess I also encountered that in order to access some tables in my MS Access database (but not for some other tables) I also need

    requires java.scripting;