Couchbase sync gate replication error


#1

working in pure java.
run couchbase replication code as:

Manager manager = new Manager(new JavaContext(“data”), Manager.DEFAULT_OPTIONS);

Manager.enableLogging(“Sync”, Log.VERBOSE);
final Database db = manager.getDatabase(“sync_gateway”);

URL url = new URL(“http://localhost:4984/sync_gateway/”);
Replication push = db.createPushReplication(url);

Replication pull = db.createPullReplication(url);
pull.setContinuous(true);
push.setContinuous(true);
com.couchbase.lite.auth.Authenticator auth = AuthenticatorFactory.createBasicAuthenticator(“GUEST”, “”);
push.setAuthenticator(auth);
push.setAuthenticator(auth);
pull.setAuthenticator(auth);
push.start();
pull.start();

on this line: Replication push = db.createPushReplication(url);
it through following exception:

Exception in thread “Thread-0” java.lang.NoClassDefFoundError: org/apache/http/client/CookieStore
at com.couchbase.lite.Database.createPushReplication(Database.java:696)
at test_couchbase.GreetingServer.run(GreetingServer.java:78)
Caused by: java.lang.ClassNotFoundException: org.apache.http.client.CookieStore
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
… 2 more


#2

Hello @zeeshan_niazi,

The code looks logical and correct. Curious what is the path of your JAR file and which JAR are you using?


#3

as I build jar files through gradlew command, and jar are in my documents folder and I added those jar files from that folder. but it shows this exception.


#4

Hi @zeeshan_niazi,

According to the log message, runtime can not find HttpClient.
Could you please download Couchbase Lite Java package from http://packages.couchbase.com/builds/mobile/java/1.0.4/1.0.4-28/couchbase-lite-java-1.0.4-28-community.zip
You can copy httpclient-4.0-beta1.jar and httpcore-4.0-beta2.jar to your project.

Thanks!
Hideki