Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Required jars for RestEasy Client

I need to provide a java REST client, which should contain all required jars in one bundle. I chose RestEasy as REST framwork, since the server application is done on a JBoss.

Nearly all examples I found so far use either an application container environment, where those libs are provided and thus only the Java EE API is needed during compile or are build with Maven and thus dependencies are resolved automatically, which maybe be a good idea and the current standard way to do it, but for project-related reasons I need the jars in a lib folder and be able to include during the build and wihtin an executable jar.

So my question is, which jars a necessary to build a simple client which can do something like that:

ResteasyClient client = new ResteasyClientBuilder().build();
ResteasyWebTarget target = client.target(myURL).queryParam("param",
                "value");
Builder builder = target.request(MediaType.APPLICATION_JSON).header("user", "abc");
Invocation invocation = builder.buildGet();
MyResponseObject response = invocation.invoke(MyResponseObject .class);
like image 712
Alexander Rühl Avatar asked Dec 06 '22 23:12

Alexander Rühl


2 Answers

The easiest way is to use Maven. The reason I say this, is that the main artifact you want is the resteasy-client artifact, but this artifact has dependencies on other artifacts. If I create a new Maven project, add only this dependency

<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-client</artifactId>
    <version>3.0.9.Final</version>
</dependency>

The project will pull in all this artifacts

enter image description here

But if you are not using Maven, You can download the entire resteasy package here. It comes with a lot more than what you'll need, but it will have all the jars you see in the image above, along with some other goodies like user guides, examples and such. Base on the image above, just get the jars you need. Make sure you download the final-all version. When you unzip it, all the jars should be in the lib dir.

Another thing I might mention is that in order to unmarshal JSON representation into your Java classes, you might also need resteasy-jackson2-provider. Doing the same as above, you will see these pulled in artifacts

enter image description here

Again, these are also include in the download. This will work in most cases, if you are using JAXB annotations (which could return XML or JSON), because of the pulled in artifact jackson-module-jaxb-annotations, but that artifact doesn't support all JAXB annotations, so you might need to pull in the resteasy-jaxb-provider, if need be. Again like I said, just the jackson2-provider may be enough. But in the case you do need the jaxb-prodiver, here's what it looks like

enter image description here

Again, included in the download

like image 54
Paul Samsotha Avatar answered Dec 20 '22 12:12

Paul Samsotha


If you use maven in your project, you can type dependency:tree to see hierarchy of your dependencies. Libraries used by RestEasy will be listed in tree.

like image 45
Tomasz Godziński Avatar answered Dec 20 '22 12:12

Tomasz Godziński