danieln danieln - 26 days ago 8
reST (reStructuredText) Question

Jersey Client IPv6

Can I use Jersey Client to connect to a REST resource using IPv6?

I'm getting this error:

com.sun.jersey.api.client.ClientHandlerException: java.net.MalformedURLException: For input string: ":94ea:d2bc:c189:209c%10:8100"
at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:128)
at com.sun.jersey.api.client.Client.handle(Client.java:551)
at com.sun.jersey.api.client.WebResource.handle(WebResource.java:556)
at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:69)
at com.sun.jersey.api.client.WebResource$Builder.put(WebResource.java:475)
at com.bmc.aps.agent.jersey.JerseyClient.put(JerseyClient.java:168)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.net.MalformedURLException: For input string: ":94ea:d2bc:c189:209c%10:8100"
at java.net.URL.<init>(URL.java:601)
at java.net.URL.<init>(URL.java:464)
at java.net.URL.<init>(URL.java:413)
at java.net.URI.toURL(URI.java:1081)
at com.sun.jersey.client.urlconnection.URLConnectionClientHandler._invoke(URLConnectionClientHandler.java:139)
at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:126)
... 8 more


In the exception the ip is cut (
:94ea:d2bc:c189:209c%10
instead of
fe80::94ea:d2bc:c189:209c%10
).
In debug, I can see that the web resource URI is OK.

Answer

Found the answer.

Jersey Client expect to get the IP with square parentheses [].

In this example - [fe80::94ea:d2bc:c189:209c%10] instead of - fe80::94ea:d2bc:c189:209c%10.