I can't seem to get JAX-RS clients to use a web proxy on Java 8. I'm using RESTEasy 3.0.10.Final, and running from inside Eclipse 4.4.2 on Windows 7 Professional 64-bit.
I set up a FreeProxy server on localhost
running at 192.168.1.123:3128
. I turn logs on and telnet to 192.168.1.123 3128 and issue a manual GET
. The request shows up in the logs.
I then fire up my Java application, setting http.proxyHost=192.168.1.123
and http.proxyPort=3128
in the system properties. (I've even tried it using -D
when starting the JVM.) (Note that I wouldn't expect the localhost
problem to come into play, as I'm connecting to an actual IP address, not to localhost
.)
I create a JAX-RS client using ClientBuilder.newBuilder().build()
and perform a GET
to a resource. Nothing shows up in the FreeProxy logs.
What do I have to do in order to get JAX-RS clients to use a proxy?
Both Jersey and RESTEasy provide their own implementation. The difference is that Jersey additionally provides something called Chunked Output. It allows the server to send back to the client a response in parts (chunks).
Overview. JAX-RS, JSR-311, is a new JCP specification that provides a Java API for RESTful Web Services over the HTTP protocol. Resteasy is an portable implementation of this specification which can run in any Servlet container.
RESTeasy is a Java library that provides a simple interface to the REST server. It supports all of the features of the Jakarta REST Services and includes support for both synchronous and asynchronous communication. Firstly, there are really two ways to create a REST Client. Use Jakarta REST Client API.
RESTEasy is a JBoss / Red Hat project that provides various frameworks to help you build RESTful Web Services and RESTful Java applications. It is an implementation of the Jakarta RESTful Web Services, an Eclipse Foundation specification that provides a Java API for RESTful Web Services over the HTTP protocol.
It seems to be possible to make RESTeasy use Java's proxy properties (e.g. -Dhttp.proxyHost
) by using a different engine instead of HttpClient
. java.net.HttpURLConnection
supports proxy properties out of the box:
ResteasyClient client = new ResteasyClientBuilder().httpEngine(new URLConnectionEngine()).build();
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