JSON-P and JAX-RS 2 Client Maven Dependencies For RESTEasy

RESTEasy is a JAX-RS 2.0 implementation and comes with JAX-RS 2.0 client implementation / provider.

To use RESTEasy as a JAX-RS 2.0 client implementation (e.g. for system testing) you will have to declare the following dependencies in pom.xml:


<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-client</artifactId>
    <version>3.0.10.Final</version>
</dependency>
<dependency>
	<groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-json-p-provider</artifactId>
    <version>3.0.10.Final</version>
</dependency>

The choice of the JAX-RS implementation does not have any effect at the code--it remains implementation independent:

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;

@Test
public void oracle() {
	Client client = ClientBuilder.newClient();
	String content = client.target("http://www.oracle.com/technetwork/java/index.html").
			request().
			get(String.class);
	assertNotNull(content);
	assertTrue(content.contains("java"));
}

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting

Comments:

If you are using WildFly 8.2.0.Final and like a small war file ;o) - just add the next line to META-INF/MENIFEST.MF in the war file and you can change scope to provided.

Dependencies: org.jboss.resteasy.resteasy-jaxrs,org.jboss.resteasy.resteasy-json-p-provider

Part of the pom.xml

<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
<version>3.0.10.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-json-p-provider</artifactId>
<version>3.0.10.Final</version>
<scope>provided</scope>
</dependency>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<archive>
<manifestEntries>
<Dependencies>org.jboss.resteasy.resteasy-jaxrs,org.jboss.resteasy.resteasy-json-p-provider</Dependencies>
</manifestEntries>
</archive>
</configuration>
</plugin>

Posted by Michael Bornholdt Nielsen on January 14, 2015 at 10:11 AM CET #

Hi Adam,

Can you please add some simple and complex jax-rs 2.0 async examples?

Posted by Eyal on January 14, 2015 at 07:21 PM CET #

Post a Comment:
  • HTML Syntax: NOT allowed
...the last 150 posts
...the last 10 comments
License