I'm very new to RestAPI and I'm stuck with this problem. I'm trying to send a request using the Rest Client to my Wildfly Server, but I get this error:
javax.ws.rs.WebApplicationException: Unknown error, status code 405
at org.jboss.resteasy.microprofile.client.DefaultResponseExceptionMapper.toThrowable(DefaultResponseExceptionMapper.java:21)
at org.jboss.resteasy.microprofile.client.ExceptionMapping$HandlerException.mapException(ExceptionMapping.java:41)
at org.jboss.resteasy.microprofile.client.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:153)
at jdk.proxy2/jdk.proxy2.$Proxy29.easy(Unknown Source)
at UserResourceImplIT.add(UserResourceImplIT.java:30)
This is my test:
import java.net.URI;
import java.util.Date;
import javax.ws.rs.core.Response;
import org.eclipse.microprofile.rest.client.RestClientBuilder;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import com.tech11.startingasbackend.business.boundary.UserResource;
import com.tech11.startingasbackend.business.entity.CreateUserDTO;
public class UserResourceImplIT {
private UserResource client;
@BeforeEach
public void init() {
URI uri = URI.create("http://localhost:8080/starter");
this.client = RestClientBuilder
.newBuilder()
.baseUri(uri)
.build(UserResource.class);
}
@Test
public void add() {
Response response = this.client.easy("HELLO");
}
}
My Interface:
public interface UserResource {
@POST
Response easy(String message);
}
And my implementation:
public class UserResourceImpl implements UserResource {
@Override
public Response easy(String message) {
return Response.ok().build();
}
When I remove the @Path("/user") annotation from my Interface, the bug disappears, but nothing is posted in the database. Does anyone know what I'm missing and why this error occurs or how to proceed?