NoClassDefFoundError : com.couchbase.lite.ConnectionStatus

This is a naive question. I have a simple gradle project (in IntelliJ) on Ubuntu with the dependencies specified as below:

dependencies {
testImplementation ‘org.junit.jupiter:junit-jupiter-api:5.6.0’
testRuntimeOnly ‘org.junit.jupiter:junit-jupiter-engine’
implementation “com.couchbase.lite:couchbase-lite-java-ee:2.8.1”
implementation “com.couchbase.client:java-client:3.1.0”
}

My code compiles fine. However during runtime, at this line:

CouchbaseLite.init();

I am getting the error:

Exception in thread “main” java.lang.NoClassDefFoundError: com.couchbase.lite.ConnectionStatus
at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:383)
at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:227)
at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:169)
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:1787)
at java.base/java.lang.System.load(System.java:581)
at com.couchbase.lite.internal.NativeLibrary.load(NativeLibrary.java:61)
at com.couchbase.lite.internal.CouchbaseLiteInternal.init(CouchbaseLiteInternal.java:75)
at com.couchbase.lite.CouchbaseLite.init(CouchbaseLite.java:50)
at com.couchbase.lite.CouchbaseLite.init(CouchbaseLite.java:33)
at GettingStarted.main(GettingStarted.java:42)

To me it seems like couchbaselite library is not getting picked up at runtime. Any help will be greatly appreciated.

Did you follow the instructions in the documentation regarding Linux setups?

1 Like

We can do better with the error message.

If you still get this message after following the setup instructions, you might verify that the directory associated with the java property ‘java.io.tmpdir’ is writeable. If it is null (or empty) the code will use the process current directory.

Yes I have followed the instructions mentioned in the page. If I run the application outside the IntelliJ IDE via commandline, I am now able to get it to work. So I assume some configuration with IntelliJ IDE is wrong which is causing the issue.