Issue in pull replication for couchbase lite java

Hi all,

I am using couchbase lite for java for my windows application.
In my code I am successfully able to push my local data on the couchbase server. However when I am trying to pull it, it is unable to do so. Earlier I was trying to do it with couchbase-lite-java-1.2.1. It displayed no error in the log.
So now I am trying to do it using couchbase-lite-java-1.3.1. But I am getting the following error:

Library not found: /native/windows/x86/CouchbaseLiteJavaForestDB.dll
Error loading library: CouchbaseLiteJavaForestDB
java.lang.NullPointerException
at com.couchbase.lite.util.NativeLibUtils.loadLibrary(NativeLibUtils.java:45)
at com.couchbase.lite.store.ForestDBStore.(ForestDBStore.java:75)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at com.couchbase.lite.Database.createStoreInstance(Database.java:1156)
at com.couchbase.lite.Database.open(Database.java:1221)
at com.couchbase.lite.Manager.openDatabase(Manager.java:335)
at com.couchbase.lite.Manager.getDatabase(Manager.java:299)
at pluginforcouchbase.actions.CouchbaseConnection.ConnectToDatabase(CouchbaseConnection.java:73)
at pluginforcouchbase.actions.CouchbaseDataManupulation.connect(CouchbaseDataManupulation.java:27)
at pluginforcouchbase.actions.CouchbaseDataManupulation.updateDocInDb(CouchbaseDataManupulation.java:60)
at pluginforcouchbase.actions.TestCouchbase.test2(TestCouchbase.java:37)
at pluginforcouchbase.actions.TestCouchbase.main(TestCouchbase.java:44)
Sep 26, 2016 2:53:28 PM com.couchbase.lite.util.SystemLogger e
SEVERE: Database: ERROR: Failed to load CouchbaseLiteJavaForestDB
Library not found: /native/windows/x86/sqlcipher.dll
Sep 26, 2016 2:53:28 PM com.couchbase.lite.util.SystemLogger e
SEVERE: CBLite: Cannot find library: sqlcipher
Library not found: /native/windows/x86/sqlite3.dll
Sep 26, 2016 2:53:28 PM com.couchbase.lite.util.SystemLogger e
SEVERE: CBLite: Cannot find library: sqlite3
JavaSQLiteStorageEngine
Sep 26, 2016 2:53:28 PM com.couchbase.lite.util.SystemLogger e
SEVERE: Database: Cannot load native library
Library not found: /native/windows/x86/sqlcipher.dll
Sep 26, 2016 2:53:28 PM com.couchbase.lite.util.SystemLogger e
SEVERE: CBLite: Cannot find library: sqlcipher
Library not found: /native/windows/x86/sqlite3.dll
Sep 26, 2016 2:53:28 PM com.couchbase.lite.util.SystemLogger e
SEVERE: CBLite: Cannot find library: sqlite3
Sep 26, 2016 2:53:28 PM com.couchbase.lite.util.SystemLogger e
SEVERE: Database: Cannot load native library

Why is it trying to fetch DLLs when I am working with Java Jars.

I am just trying to create a manager object and fetching my database. Following is my source code:

try {
manager = new Manager(new JavaContext("\DatabaseData"),
Manager.DEFAULT_OPTIONS);
database = manager.getDatabase(dbName);// create or open database
} catch (CouchbaseLiteException e) {
e.printStackTrace();
}

Is this a bug in the new JAR? or am I doing something wrong ?
@simonbasle @jens

That looks like a packaging issue. Can you file an issue here? https://github.com/couchbase/couchbase-lite-android

Hi @aniket.khedekar,
Thank you for reporting this issue.
I assume you downloaded couchbase lite for Java from Couchbase download site. I confirmed that Zip file does not include CouchbaseLiteJavaForestDB.dll.
Best regards,
Hideki

HI @aniket.khedekar,
Fixing the download site could take time. If you are in hurry, please download the couchbase-lite-java v1.3.1 from following link?
http://latestbuilds.hq.couchbase.com/couchbase-lite-java/1.3.1/1.3.1-13/
Regards,
Hideki

Hi @aniket.khedekar,
We also fixed download site. Now correct zip files are available.
Thanks!
Hideki

Hi @hideki,

Thanks for your prompt response. I’ve now downloaded the new zip file.

However I am now getting the following errors:

Library not found: /native/windows/x86/sqlcipher.dll
Sep 27, 2016 10:03:29 AM com.couchbase.lite.util.SystemLogger e
SEVERE: CBLite: Cannot find library: sqlcipher
JavaSQLiteStorageEngine
Library not found: /native/windows/x86/sqlcipher.dll
Sep 27, 2016 10:03:30 AM com.couchbase.lite.util.SystemLogger e
SEVERE: CBLite: Cannot find library: sqlcipher

Also still I am unable to get the pull operation successfully for my application.
Both the following methods return null.

pull.getPendingDocumentIDs();
pull.getDocIds();

Kindly suggest.

Hi @aniket.khedekar,

I am not sure where sqlcipher.dll keyword comes from. CBL Java does not dynamically link to sqlcipher.dll. Do you use SQLCipher? How do you integrate SQLCipher into your project? Can you share your development environment? I will try to reproduce with Windows machine.

Both getPendingDocumentIDs() and getDocIds() are only push replication feature. For pull replication, they just return null.

Thanks!
Hideki

Hi @hideki,

I am not using SQLCipher anywhere in my code. Till now I am just trying to run the following code:

Manager manager = new Manager(new JavaContext(), Manager.DEFAULT_OPTIONS);
Database database = manager.getDatabase(dbName) ;

and getting the following issue when executing manager.getDatabase(dbName):

Library not found: /native/windows/x86/sqlcipher.dll
Sep 27, 2016 12:32:36 PM com.couchbase.lite.util.SystemLogger e
SEVERE: CBLite: Cannot find library: sqlcipher
JavaSQLiteStorageEngine
Library not found: /native/windows/x86/sqlcipher.dll
Sep 27, 2016 12:32:37 PM com.couchbase.lite.util.SystemLogger e
SEVERE: CBLite: Cannot find library: sqlcipher

Following is my environment:
IDE: Eclipse (Neon Release (4.6.0)),
OS: Windows 8 (32 bit)
Processor: Intel i5-3230M 2.60GHz
JRE: 1.8.0_51
Couchbase lite Java 1.3.1

I’ve created a basic java project for evaluating Couchbase lite as an offline option for my windows application.

Please let me know if u require any more details.

@hideki
For what it’s worth, the linux and os x folders have libsqlcipher in them, but the windows folder does not have sqlcipher.dll.

@aniket.khedekar
One experiment you can try is unzipping the jar, putting this file into the native/windows/x86 folder and rejarring it.

@borrrden,
Thank you for your inputs. As you wrote, libsqlcipher.so/dylib for Linux and OSX are in JAR file. But not sqlicipher.dll for Windows in Windows. This requires to fix build script for Windows.
Thanks!

I filed the ticket for sqlcipher.dll issue https://github.com/couchbase/couchbase-lite-java-core/issues/1455

Hi @aniket.khedekar,
We will fix sqlcipher.dll issue on windows with next release. Till it will be available, please use solution @borrrden posted earlier.

you could download pre-built DLLs from https://github.com/couchbaselabs/couchbase-lite-libsqlcipher/tree/master/libs/windows
you could add DLLs into jar file by jar ut couchbase-lite-java-sqlcipher.jar /native/windows/x86/sqlcipher.dll
https://docs.oracle.com/javase/tutorial/deployment/jar/update.html
Thanks,

Any update on when this fix will be live, if it isn’t already? Thanks!

@nwalters512,
Don’t you mind to add Windows sqlcipher DLLs into couchbase-lite-java-sqlcipher.jar by yourself?

I will go ahead and do that, I just saw that the PR had been accepted months ago and figured it should hopefully make it into a production version soon. Thanks!