cloudant / java-cloudant

A Java client for Cloudant
Apache License 2.0
79 stars 68 forks source link

com.cloudant.client.org.lightcouch.CouchDbException: Error retrieving server response #312

Closed sandrodesantis closed 8 years ago

sandrodesantis commented 8 years ago

Please include the following information in your ticket.

I'm able to connect database, and run methods like:

Server Version: 1.6.1 All my databases : _replicator _users dash-um-db example_db

or

are working very well.

But, when I try use methods like:

// Check index db.createIndex("type", null, null, new IndexField[] { new IndexField("type",SortOrder.asc)});

or

// Find List myTOList = db.findByIndex("\"selector\": {\"type\": \"adoption\"}", AdoptionTO.class); System.out.println("myTOList " + myTOList);

I have this issue: [err] Caused by: java.net.ProtocolException: Server rejected operation [err] at sun.net.www.protocol.http.HttpURLConnection.expect100Continue(HttpURLConnection.java:1218) [err] at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(HttpURLConnection.java:1297) [err] at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1258) [err] at com.cloudant.http.HttpConnection.execute(HttpConnection.java:233) [err] at com.cloudant.client.org.lightcouch.CouchDbClient.execute(CouchDbClient.java:475) [err] ... 82 more

Any idea ?

Thanks.

Sandro

ricellis commented 8 years ago

This is basically the same problem as #218 and has been fixed since version 2.4.1. I recommend using the latest release 2.6.2.

sandrodesantis commented 8 years ago

Hi,

I updated versions, now I'm using:

cloudant-client-2.6.2.jar cloudant-http-2.6.2.jar commons-codec-1.6.jar commons-io-2.4.jar gson-2.7.jar

And I'm receiving another ERROR message, looks like PUT commands don't working.

These commands are working very well:

// Note: for Cloudant Local or Apache CouchDB use: CloudantClient client = ClientBuilder.url(new URL("http://0.0.0.0:5984")).username("admin") .password("xxxx").disableSSLAuthentication().build();

// Show the server version System.out.println("Server Version: " + client.serverVersion());

// Show databases System.out.println("Dbs: " + client.getAllDbs());

// Get database Database db1 = client.database("dash-db", true);

These commands are NOT working :

=> not working! db1.createIndex("type", "type", null, new IndexField[]{ new IndexField("type",SortOrder.asc)});

=> not working List objTOList = db.findByIndex("\"selector\": {\"type\": \"adoption\"}", ObjTO.class); System.out.println("objTOList " + objTOList);

Exception =>

CouchDbInfo [dbName=dash-um-db, docCount=4, docDelCount=4, updateSeq=16, purgeSeq=0, compactRunning=false, diskSize=65640, instanceStartTime=1477654845132730, diskFormatVersion=6] [err] com.cloudant.client.org.lightcouch.CouchDbException: 400 Bad Request: bad_request: Referer header required. [err] at com.cloudant.client.org.lightcouch.CouchDbClient.execute(CouchDbClient.java:524) [err] at com.cloudant.client.org.lightcouch.CouchDbClient.executeToInputStream(CouchDbClient.java:572) [err] at com.cloudant.client.api.Database.createIndex(Database.java:305) [err] at com.cloudant.client.api.Database.createIndex(Database.java:288)

Any idea, thanks !

rhyshort commented 8 years ago

This appears to be the same as #313, discussion will take place there. Let us know if this is not the case.