java - Cloudant j2se prototype throwing HTTPRequest exception -
i'm trying follow replication guide on github cloudant prototype basic 1 way connection between local couchdb , and locally running j2se app utilizing cloudant sync library.
the local datastore file being created, after running application, i'm getting runtime error - @ glance i'm little unsure of how resolve: asside cloudant code , dependancies;
this entire code app - have apache couchdb installed on machine , database called 'baseball' exists already:
import com.cloudant.sync.datastore.datastoremanager; import com.cloudant.sync.datastore.datastore; import com.cloudant.sync.replication.*; import com.cloudant.sync.notifications.*; import com.google.common.eventbus.subscribe; import java.util.concurrent.countdownlatch; import java.io.*; import java.net.*; //https://github.com/cloudant/sync-android/blob/master/doc/replication.md public class cloudapp{ public static void main(string [] args) throws exception{ file path = new file("datastores"); system.out.println(path.getabsolutepath()); datastoremanager manager = new datastoremanager(path.getabsolutepath()); uri uri = new uri("http://127.0.0.1:5984/baseball"); datastore ds = manager.opendatastore("my_datastore"); // create replictor replicates changes remote // database local datastore. replicator replicator = replicatorfactory.oneway(uri, ds); // use countdownlatch provide lightweight way wait completion countdownlatch latch = new countdownlatch(1); listener listener = new listener(latch); replicator.geteventbus().register(listener); replicator.start(); latch.await(); replicator.geteventbus().unregister(listener); if (replicator.getstate() != replicator.state.complete) { system.out.println("error replicating remote"); system.out.println(listener.error); } } } class listener { private final countdownlatch latch; public errorinfo error = null; listener(countdownlatch latch) { this.latch = latch; } @subscribe public void complete(replicationcompleted event) { latch.countdown(); } @subscribe public void error(replicationerrored event) { this.error = event.errorinfo; latch.countdown(); } }
and runtime error log outputs:
[i]datastoremanager: path: /users/reecegriffin/documents/workspace/cloudant 2/datastores [i]datastoremanager: dbdirectory: /users/reecegriffin/documents/workspace/cloudant 2/datastores/my_datastore mar 10, 2014 9:29:02 com.almworks.sqlite4java.internal log info: [sqlite] db[1]: instantiated [/users/reecegriffin/documents/workspace/cloudant 2/datastores/my_datastore/db.sync] mar 10, 2014 9:29:02 com.almworks.sqlite4java.internal log info: [sqlite] internal: loaded sqlite4java-osx /users/reecegriffin/documents/workspace/cloudant 2/src/libsqlite4java-osx.jnilib mar 10, 2014 9:29:02 com.almworks.sqlite4java.internal log info: [sqlite] internal: loaded sqlite 3.7.10, wrapper 0.2 mar 10, 2014 9:29:02 com.almworks.sqlite4java.internal log info: [sqlite] db[1]: opened exception in thread "main" java.lang.illegalstateexception: java.lang.runtimeexception: stub! @ com.cloudant.mazha.httprequests.createhttpclient(httprequests.java:185) @ com.cloudant.mazha.httprequests.<init>(httprequests.java:69) @ com.cloudant.mazha.couchclient.<init>(couchclient.java:47) @ com.cloudant.sync.replication.couchclientwrapper.<init>(couchclientwrapper.java:45) @ com.cloudant.sync.replication.basicpullstrategy.<init>(basicpullstrategy.java:90) @ com.cloudant.sync.replication.pullreplication.createreplicationstrategy(pullreplication.java:40) @ com.cloudant.sync.replication.basicreplicator.getreplicationstrategy(basicreplicator.java:41) @ com.cloudant.sync.replication.basicreplicator.start(basicreplicator.java:61) @ cloudapp.main(cloudapp.java:27) caused by: java.lang.runtimeexception: stub! @ org.apache.http.params.abstracthttpparams.<init>(abstracthttpparams.java:5) @ org.apache.http.params.basichttpparams.<init>(basichttpparams.java:6) @ com.cloudant.mazha.httprequests.gethttpconnectionparams(httprequests.java:199) @ com.clou dant.mazha.httprequests.createhttpclient(httprequests.java:173) ... 8 more
many help. regards, reece.
i noticed in other threads regarding stub related apache commons httpclient related stuff, android library build path order can have effect. trying run within eclipse & sure enough - after opened build path editor , moved android.jar last on build path, run time error went away.
Comments
Post a Comment