I'm having issue on Errai Jax-rs, I'm not sure why this would not work:
@Path("userservice")
public interface UserService {
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public void login(LoginForm login);
}
And when called from the UI:
service.call(new RemoteCallback<Void>() {
@Override
public void callback(Void response) {
// Do stuff
}
}, new ErrorCallback() {
@Override
public boolean error(Message message, Throwable throwable) {
return false;
}
}).login(new LoginForm(this.username.getText(),
this.password.getText(),
true));
Throws this error:
[INFO] DEBUG [SynchronousDispatcher] PathInfo: /userservice
[INFO] DEBUG [ExceptionHandler] Failed executing POST /userservice
[INFO] org.jboss.resteasy.spi.MethodNotAllowedException: No resource method found for POST, return 405 with Allow header
[INFO] at org.jboss.resteasy.core.registry.Segment.match(Segment.java:112)
[INFO] at org.jboss.resteasy.core.registry.PathParamSegment.matchPattern(PathParamSegment.java:200)
[INFO] at org.jboss.resteasy.core.registry.RootSegment.matchChildren(RootSegment.java:339)
[INFO] at org.jboss.resteasy.core.registry.RootSegment.matchRoot(RootSegment.java:374)
[INFO] at org.jboss.resteasy.core.registry.RootSegment.matchRoot(RootSegment.java:367)
[INFO] at org.jboss.resteasy.core.ResourceMethodRegistry.getResourceInvoker(ResourceMethodRegistry.java:354)
[INFO] at org.jboss.resteasy.core.SynchronousDispatcher.getInvoker(SynchronousDispatcher.java:231)
[INFO] at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:170)
[INFO] at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)
[INFO] at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
[INFO] at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
[INFO] at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
[INFO] at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
[INFO] at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
[INFO] at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:66)
[INFO] at com.googlecode.objectify.cache.AsyncCacheFilter.doFilter(AsyncCacheFilter.java:39)
[INFO] at com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:163)
[INFO] at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:58)
[INFO] at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
[INFO] at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
[INFO] at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
[INFO] at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
[INFO] at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
[INFO] at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
[INFO] at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
[INFO] at com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:163)
[INFO] at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:58)
[INFO] at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:118)
[INFO] at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:113)
[INFO] at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
[INFO] at com.google.appengine.api.socket.dev.DevSocketFilter.doFilter(DevSocketFilter.java:74)
[INFO] at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
[INFO] at com.google.appengine.tools.development.ResponseRewriterFilter.doFilter(ResponseRewriterFilter.java:123)
[INFO] at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
[INFO] at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:34)
[INFO] at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
[INFO] at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:63)
[INFO] at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
[INFO] at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
[INFO] at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
[INFO] at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:125)
[INFO] at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
[INFO] at com.google.appengine.tools.development.DevAppServerServersFilter.doDirectRequest(DevAppServerServersFilter.java:369)
[INFO] at com.google.appengine.tools.development.DevAppServerServersFilter.doDirectServerRequest(DevAppServerServersFilter.java:352)
[INFO] at com.google.appengine.tools.development.DevAppServerServersFilter.doFilter(DevAppServerServersFilter.java:115)
[INFO] at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
[INFO] at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
[INFO] at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
[INFO] at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
[INFO] at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
[INFO] at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
[INFO] at com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:97)
[INFO] at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
[INFO] at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:438)
[INFO] at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
[INFO] at org.mortbay.jetty.Server.handle(Server.java:326)
[INFO] at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
[INFO] at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:938)
[INFO] at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
[INFO] at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
[INFO] at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
[INFO] at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
[INFO] at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
I got the same Exception when trying to access a Service via RestEasy. So in case someone else stumbles upon it:
as Andreas already mentioned, it often refers to a wrong URL.
In my case i could call my Service via Postman or the resteasy target with
final String path = "http://localhost:8080/repository/user";
e.g.
Client client = ClientBuilder.newBuilder().build();
WebTarget target = client.target("http://localhost:8080/repository/user");
Response response = target.request().get();
while using a Resteasy-Proxy i had to use
final String path = "http://localhost:8080/repository";
e.g.
ResteasyClient client = new ResteasyClientBuilder().build();
ResteasyWebTarget target = client.target(UriBuilder.fromPath("http://localhost:8080/repository"));
IUserTestRepository proxy = target.proxy(IUserTestRepository.class);