Riak Java Client Error

Russell Brown russell.brown at me.com
Wed Mar 30 09:13:49 EDT 2011


Hi Muhammad,
The riak java client depends on a couple of external libraries (eg. Apache commons HttpClient, google protobufs). These need to be on your class path when you run your program. The easiest way to do this is to use maven[1]. Using maven means you can simply declare the client as a dependency of your project and maven will take care of downloading the jar (and it's dependent jars). If you are using an IDE (like eclipse) you can then get up and running very quickly indeed.

Quick start:

1. get maven
2. run mvn archetype:generate
3. edit the pom.xml (that mvn generated) and add the following to dependencies  <---- If you already have a project this is all you need to do.

<dependency>
  <groupId>com.basho.riak</groupId>
  <artifactId>riak-client</artifactId>
  <version>0.14.0</version>
  <type>pom</type>
</dependency>

4. run mvn clean:install
5 . [optional] if you have eclipse installed run mvn eclipse:eclipse to generate project and class path files.
6. start hacking

Of course, if you don't want to get involved with maven you can just grab the following jars and put them on your class path:

riak-client-0.14.0.jar
commons-codec-1.2.jar 
commons-httpclient-3.1.jar
commons-logging-1.0.4.jar
protobuf-java-2.3.0.jar

Have a read of the README at https://github.com/basho/riak-java-client/

and post back here if you have any trouble.

Cheers

Russell

[1] http://maven.apache.org/download.html (I recommend 2.2.1)

On 30 Mar 2011, at 13:38, Muhammad Yousaf wrote:

> Hi,
> 
> While playing with riak java client i am getting lots of error 
> 
> this is my code 
> 
> import com.basho.riak.client.RiakClient;
> import com.basho.riak.client.RiakObject;
> import com.basho.riak.client.response.FetchResponse;
> 
> public class RiakTest {
> 
>     public static void main(String[] args) {
> 
>         // connect
>         RiakClient riak = new RiakClient("http://localhost:8098/riak");
> 
>         // create object
>         RiakObject o = new RiakObject("mybucket", "mykey", "myvalue");
> 
>         // store
>         riak.store(o);  
>     }
> }
> 
> 
> getting errors like 
> 
> ./com/basho/riak/client/RiakClient.java:20: package org.apache.commons.httpclient does not exist
> import org.apache.commons.httpclient.HttpClient;
>                                     ^
> ./com/basho/riak/client/util/ClientHelper.java:21: package org.apache.commons.codec.binary does not exist
> import org.apache.commons.codec.binary.Base64;
>                                       ^
> ./com/basho/riak/client/util/ClientHelper.java:22: package org.apache.commons.httpclient does not exist
> import org.apache.commons.httpclient.HttpClient;
>                                     ^
> ./com/basho/riak/client/util/ClientHelper.java:23: package org.apache.commons.httpclient does not exist
> import org.apache.commons.httpclient.HttpMethod;
>                                     ^
> ./com/basho/riak/client/util/ClientHelper.java:24: package org.apache.commons.httpclient.methods does not exist
> import org.apache.commons.httpclient.methods.ByteArrayRequestEntity;
>                                             ^
> ./com/basho/riak/client/util/ClientHelper.java:25: package org.apache.commons.httpclient.methods does not exist
> import org.apache.commons.httpclient.methods.DeleteMethod;
>                                             ^
> ./com/basho/riak/client/util/ClientHelper.java:26: package org.apache.commons.httpclient.methods does not exist
> import org.apache.commons.httpclient.methods.GetMethod;
>                                             ^
> ./com/basho/riak/client/util/ClientHelper.java:27: package org.apache.commons.httpclient.methods does not exist
> import org.apache.commons.httpclient.methods.HeadMethod;
>                                             ^
> ./com/basho/riak/client/util/ClientHelper.java:28: package org.apache.commons.httpclient.methods does not exist
> import org.apache.commons.httpclient.methods.PostMethod;
>                                             ^
> ./com/basho/riak/client/util/ClientHelper.java:29: package org.apache.commons.httpclient.methods does not exist
> import org.apache.commons.httpclient.methods.PutMethod;
>                                             ^
> ./com/basho/riak/client/util/ClientHelper.java:30: package org.apache.commons.httpclient.methods does not exist
> import org.apache.commons.httpclient.methods.StringRequestEntity;
>                                             ^
> 
> 
> ./com/basho/riak/client/response/DefaultHttpResponse.java:20: package org.apache.commons.httpclient does not exist
> import org.apache.commons.httpclient.HttpMethod;
>                                     ^
> ./com/basho/riak/client/response/DefaultHttpResponse.java:36: cannot find symbol
> symbol  : class HttpMethod
> location: class com.basho.riak.client.response.DefaultHttpResponse
>     private HttpMethod httpMethod = null;
>             ^
> ./com/basho/riak/client/response/DefaultHttpResponse.java:39: cannot find symbol
> symbol  : class HttpMethod
> location: class com.basho.riak.client.response.DefaultHttpResponse
>             InputStream stream, HttpMethod httpMethod) {
>                                 ^
> ./com/basho/riak/client/response/DefaultHttpResponse.java:88: cannot find symbol
> symbol  : class HttpMethod
> location: class com.basho.riak.client.response.DefaultHttpResponse
>     public HttpMethod getHttpMethod() {
>            ^
> RiakTest.java:13: cannot find symbol
> symbol  : constructor RiakObject(java.lang.String,java.lang.String,java.lang.String)
> location: class com.basho.riak.client.RiakObject
>         RiakObject o = new RiakObject("mybucket", "mykey", "myvalue");
> 
> 
> 
> Can anyone tell what i am doing wrong ???
> 
> 
> 
> Regards,
> 
> Muhammad Yousaf
> 
> 
> _______________________________________________
> riak-users mailing list
> riak-users at lists.basho.com
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.basho.com/pipermail/riak-users_lists.basho.com/attachments/20110330/14ea9751/attachment.html>


More information about the riak-users mailing list