java.io.EOFException while retrieving data from Riak

838 views Asked by At

I am trying to execute a simple fetching of data as a string from Riak.

We are trying to execute a sample code and we are getting the error. It's a Java code written for fetching data from Riak

I made sure riak is running by Sudo Riak Start

Error as follows:

Exception in thread "main" com.basho.riak.client.RiakRetryFailedException: java.io.EOFException
    at com.basho.riak.client.cap.DefaultRetrier.attempt(DefaultRetrier.java:79)
    at com.basho.riak.client.cap.DefaultRetrier.attempt(DefaultRetrier.java:81)
    at com.basho.riak.client.cap.DefaultRetrier.attempt(DefaultRetrier.java:81)
    at com.basho.riak.client.cap.DefaultRetrier.attempt(DefaultRetrier.java:81)
    at com.basho.riak.client.cap.DefaultRetrier.attempt(DefaultRetrier.java:53)
    at com.basho.riak.client.bucket.FetchBucket.execute(FetchBucket.java:72)
    at riak.App.main(App.java:15)
Caused by: java.io.EOFException
    at java.io.DataInputStream.readInt(DataInputStream.java:392)
    at com.basho.riak.pbc.RiakConnection.receive(RiakConnection.java:110)
    at com.basho.riak.pbc.RiakClient.getBucketProperties(RiakClient.java:697)
    at com.basho.riak.client.raw.pbc.PBClientAdapter.fetchBucket(PBClientAdapter.java:249)
    at com.basho.riak.client.bucket.FetchBucket$1.call(FetchBucket.java:74)
    at com.basho.riak.client.bucket.FetchBucket$1.call(FetchBucket.java:1)
    at com.basho.riak.client.cap.DefaultRetrier.attempt(DefaultRetrier.java:72)
    ... 6 more

Sample code:

package riak;

import com.basho.riak.client.IRiakClient;
import com.basho.riak.client.IRiakObject;
import com.basho.riak.client.RiakException;
import com.basho.riak.client.RiakFactory;
import com.basho.riak.client.bucket.Bucket;

public class App
{
    public static void main(String[] args) throws RiakException
    {
        //IRiakClient riakClient = RiakFactory.httpClient();
        IRiakClient client = RiakFactory.pbcClient("127.0.0.1", 8098);
        Bucket myBucket = client.fetchBucket("TestBucket").execute();
        IRiakObject myObject = myBucket.fetch("TestKey").execute();
        // note that getValueAsString() will return null here if there's no value in Riak
        System.out.println(myObject.getValueAsString());

        client.shutdown();
    }
}
3

There are 3 answers

0
Dark Knight On BEST ANSWER

Thank you so much for all your help.

I have found the problem!

My port # was 8087 instead of 8098

We need to configure that in /etc/riak/app.conf (Under API settings)

I have reconfigured that and It fixed it.

Thank you!

0
Joao Lucas Gondim On

The port is 8087 because you're using pbcclient. That's correct. In case of using the httpclient, the default port is 8098. That's what you were confused. And so was I, hehe.

0
user3059794 On

Signals that an end of file or end of stream has been reached unexpectedly during input. This exception is mainly used by data input streams to signal end of stream. Note that many other input operations return a special value on end of stream rather than throwing an exception.

and you can see that as below http://docs.oracle.com/javase/7/docs/api/java/io/EOFException.html