Reputation: 869
I'm working with riak. Trying to access it from Java. Here is the code:
package eee.xxx;
import com.basho.riak.client.IRiakClient;
import com.basho.riak.client.RiakException;
import com.basho.riak.client.RiakFactory;
import com.basho.riak.client.bucket.Bucket;
public class Main {
/**
* @param args
* @throws RiakException
*/
public static void main(String[] args) throws RiakException {
IRiakClient myClient = RiakFactory.httpClient("127.0.0.1");
Bucket myBucket = myClient.fetchBucket("Pacan").execute();
}
}
And after compiling, it throws such the error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/json/JSONException
at com.basho.riak.client.raw.http.HTTPClientAdapter.<init>(HTTPClientAdapter.java:85)
at com.basho.riak.client.RiakFactory.httpClient(RiakFactory.java:144)
at eee.xxx.Main.main(Main.java:18)
Caused by: java.lang.ClassNotFoundException: org.json.JSONException
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:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 3 more
I have no idea how to solve this. Please, help! :-)
Upvotes: 0
Views: 350
Reputation: 159754
Riak has a number of 3rd party library dependencies, one of which is the standard JSON library which you appear to be missing. It needs to be available on the classpath at compile & runtime. It can be found here.
As there about 8 dependencies it is easier to let Maven manage this for you by adding the dependency:
<dependency>
<groupId>com.basho.riak</groupId>
<artifactId>riak-client</artifactId>
<version>1.0.6</version>
</dependency>
Upvotes: 1