I try to implement a simple client at rest, but I get the error message "You must use at least one but not more than one http method annotation." In my server implementation, I added the http annotation to my method.
@Path("/") public class TestResource { @GET @Path("/domain/{value}") public String get(@PathParam("value") final String value) { return "Hello" + value; } }
I debugged this, the first time it didn't hit an exception at runtime. However, it makes a second call and does not work, not sure why and how.
My client as a junit test:
@Test public void testPerformRestEasy() { ResteasyClient client = new ResteasyClientBuilder().build(); ResteasyWebTarget target = client.target("http://localhost:8080/"); TestResource proxy = target.proxy(TestResource.class); String response = proxy.get("user"); Assert.assertEquals("Hellouser", response); }
The code in which it crashes
private static <T> ClientInvoker createClientInvoker(Class<T> clazz, Method method, ResteasyWebTarget base, ProxyConfig config) { Set<String> httpMethods = IsHttpMethod.getHttpMethods(method); if (httpMethods == null || httpMethods.size() != 1) { throw new RuntimeException("You must use at least one, but no more than one http method annotation on: " + method.toString()); } ClientInvoker invoker = new ClientInvoker(base, clazz, method, config); invoker.setHttpMethod(httpMethods.iterator().next()); return invoker; }
Mistake:
java.lang.RuntimeException: You must use at least one, but no more than one http method annotation on: public final void java.lang.Object.wait(long,int) throws java.lang.InterruptedException at org.jboss.resteasy.client.jaxrs.ProxyBuilder.createClientInvoker(ProxyBuilder.java:76) at org.jboss.resteasy.client.jaxrs.ProxyBuilder.proxy(ProxyBuilder.java:52) at org.jboss.resteasy.client.jaxrs.ProxyBuilder.build(ProxyBuilder.java:120) at org.jboss.resteasy.client.jaxrs.internal.ClientWebTarget.proxy(ClientWebTarget.java:72)
Does anyone know what the problem is?
java rest web-services resteasy
LifeStartsAtHelloWorld
source share