Reputation: 334
I'm using RESTEasy
to develop a simple WS client
so this my POM.XML
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson-provider</artifactId>
<version>2.2.1.GA</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<version>2.2.1.GA</version>
</dependency>
and this is my Test Code
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.logging.Level;
import javax.ws.rs.core.MediaType;
import org.compiere.framework.PO;
import org.compiere.model.X_I_Order;
import org.compiere.process.ProcessInfo;
import org.compiere.process.ProcessInfoParameter;
import org.compiere.process.SvrProcess;
import org.compiere.util.Ctx;
import org.compiere.util.DB;
import org.compiere.util.Trx;
import org.jboss.resteasy.client.ClientRequest;
import ru.compiere.report.RusReportStarter;
import com.audaxis.compiere.laserloylty.util.Carte;
import com.audaxis.compiere.laserloylty.util.IOrderRequest;
import com.audaxis.compiere.laserloylty.util.OrderHeader;
import com.audaxis.compiere.laserloylty.util.OrderLine;
import com.audaxis.compiere.model.MPInstanceProxy;
ClientRequest request = new ClientRequest("http:/MyURL"); //Error here
when i try to create a new ClientRequest
a get this Exception
java.lang.ClassCastException: com.sun.jersey.impl.provider.RuntimeDelegateImpl cannot be cast to org.jboss.resteasy.spi.ResteasyProviderFactory
at org.jboss.resteasy.spi.ResteasyProviderFactory.getInstance(ResteasyProviderFactory.java:351)
at org.jboss.resteasy.client.ClientRequest.<init>(ClientRequest.java:137)
at org.jboss.resteasy.client.ClientRequest.<init>(ClientRequest.java:132)
at org.jboss.resteasy.client.ClientRequest.<init>(ClientRequest.java:127)
at GetOrdersFromCardibox.getOrders(GetOrdersFromCardibox.java:109)
at GetOrdersFromCardibox.main(GetOrdersFromCardibox.java:226)
Can any one tell me where's the problem ?!
Upvotes: 0
Views: 8023
Reputation: 1026
If you look at the org.jboss.resteasy.client.ClientRequest in a current version, you can see that it is deprecated with the following comment:
The Resteasy client framework in resteasy-jaxrs is replaced by the JAX-RS 2.0 compliant resteasy-client module.
So you should consider to use the Jax-RS Client API with RestEasy as provider. For some documentation look at: http://docs.jboss.org/resteasy/docs/3.0.16.Final/userguide/html/RESTEasy_Client_Framework.html#d4e2141
The documentation contains the following example-code:
Client client = ClientBuilder.newClient();
... or...
Client client = ClientBuilder.newBuilder().build();
WebTarget target = client.target("http://foo.com/resource");
Response response = target.request().get();
String value = response.readEntity(String.class);
response.close(); // You should close connections!
You might need to update your dependencies to a newer version of RestEasy. You can find some help here: http://docs.jboss.org/resteasy/docs/3.0.16.Final/userguide/html/Maven_and_RESTEasy.html
Core libraries are:
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<version>3.0.16.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
<version>3.0.16.Final</version>
</dependency>
Upvotes: 1