I'm trying to access a webservice (documentation: http://docs.bittpublic.apiary.io/#reference/public-http-api/ticker/gets-the-current-ticker-data-for-a-given-currency-pair). I need to take an info from this JSON, the field "volume" from the response. But I'm having problems in the client builder. Check my code/error:
Code:
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.MediaType;
Client client = ClientBuilder.newClient();
Entity payload = Entity.json("{ 'productPair': 'BTCUSD'}");
Response response = client.target("https://api.bitt.com:8400")
.path("/ajax/v1/GetTicker")
.request(MediaType.APPLICATION_JSON_TYPE)
.post(payload);
System.out.println("status: " + response.toString());
Error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/glassfish/jersey/internal/util/collection/UnsafeValue
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2663)
at java.lang.Class.getConstructor0(Class.java:3067)
at java.lang.Class.newInstance(Class.java:408)
at javax.ws.rs.client.FactoryFinder.newInstance(FactoryFinder.java:118)
at javax.ws.rs.client.FactoryFinder.find(FactoryFinder.java:225)
at javax.ws.rs.client.ClientBuilder.newBuilder(ClientBuilder.java:86)
at javax.ws.rs.client.ClientBuilder.newClient(ClientBuilder.java:114)
at exchanges.barbados.Bitt.getTicker(Bitt.java:72)
at exchanges.barbados.Bitt.get24hrVol(Bitt.java:59)
at exchanges.barbados.Bitt.<init>(Bitt.java:51)
at main.Main.main(Main.java:363)
Caused by: java.lang.ClassNotFoundException: org.glassfish.jersey.internal.util.collection.UnsafeValue
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 12 more
Java Result: 1
I have no idea what is org/glassfish/jersey/internal/util/collection/UnsafeValue and all info I found online was about putting one webservice online, not accesing it.
The jars I added:
javax.ws.rs-api-2.0.1.jar
jersey-client-2.17.jar
You need jersey-common-2.17.jar. You can get it from here: http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.glassfish.jersey.core%22
Whenever you get a NoClassDefFoundError or a ClassNotFoundException on a third-party class, you can Google the class name and find out what jar file it should be in.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With