Search code examples
javaspringjettytogglz

Error 404 when editing feature thru Togglz Admin Console


I'm using Togglz 2.0.1.Final, in a web application with Spring 4.0.5.RELEASE and Jetty 9.2.1.v20140609.

When I try to edit a feature using Togglz Admin Console, the POST request receives an 404 status code.

Request Headers

POST /my-app/togglz/edit HTTP/1.1
Host: my-host
Connection: keep-alive
Content-Length: 78
Pragma: no-cache
Cache-Control: no-cache
Authorization: Basic *****
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Origin: http://my-host
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.152 Safari/537.36
Content-Type: application/x-www-form-urlencoded
Referer: http://my-host/my-app/togglz/edit?f=MY_FEATURE_TOGGLE
Accept-Encoding: gzip, deflate
Accept-Language: pt-BR,pt;q=0.8,en-US;q=0.6,en;q=0.4

Request Form Data

f=MY_FEATURE_TOGGLE&enabled=enabled&strategy=&p1=&p2=&p3=&p4=&p5=&p6=&p7=&p8=

Response Headers

HTTP/1.1 404 Not Found
Server: nginx
Date: Wed, 20 May 2015 18:24:12 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: close
Content-Encoding: gzip

In server-side the following exception is thrown:

javax.ws.rs.NotFoundException: Could not find resource for full path: http://my-host/my-app/
        at org.jboss.resteasy.core.registry.SegmentNode.match(SegmentNode.java:112) ~[resteasy-jaxrs-3.0.8.Final.jar:na]
        at org.jboss.resteasy.core.registry.RootNode.match(RootNode.java:43) ~[resteasy-jaxrs-3.0.8.Final.jar:na]
        at org.jboss.resteasy.core.registry.RootClassNode.match(RootClassNode.java:48) ~[resteasy-jaxrs-3.0.8.Final.jar:na]
        at org.jboss.resteasy.core.ResourceMethodRegistry.getResourceInvoker(ResourceMethodRegistry.java:444) ~[resteasy-jaxrs-3.0.8.Final.jar:na]
        at org.jboss.resteasy.core.SynchronousDispatcher.getInvoker(SynchronousDispatcher.java:234) ~[resteasy-jaxrs-3.0.8.Final.jar:na]
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:171) ~[resteasy-jaxrs-3.0.8.Final.jar:na]
        at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:220) [resteasy-jaxrs-3.0.8.Final.jar:na]
        at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56) [resteasy-jaxrs-3.0.8.Final.jar:na]
        at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51) [resteasy-jaxrs-3.0.8.Final.jar:na]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) [servlet-api-3.1.jar:3.1.0]
        at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:751) [jetty-servlet-9.2.1.v20140609.jar:9.2.1.v20140609]
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:566) [jetty-servlet-9.2.1.v20140609.jar:9.2.1.v20140609]
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) [jetty-server-9.2.1.v20140609.jar:9.2.1.v20140609]
        at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:596) [jetty-security-9.2.1.v20140609.jar:9.2.1.v20140609]
        at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:221) [jetty-server-9.2.1.v20140609.jar:9.2.1.v20140609]
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1111) [jetty-server-9.2.1.v20140609.jar:9.2.1.v20140609]
        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:498) [jetty-servlet-9.2.1.v20140609.jar:9.2.1.v20140609]
        at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:183) [jetty-server-9.2.1.v20140609.jar:9.2.1.v20140609]
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1045) [jetty-server-9.2.1.v20140609.jar:9.2.1.v20140609]
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [jetty-server-9.2.1.v20140609.jar:9.2.1.v20140609]
        at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:191) [jetty-server-9.2.1.v20140609.jar:9.2.1.v20140609]
        at org.eclipse.jetty.server.Dispatcher.error(Dispatcher.java:77) [jetty-server-9.2.1.v20140609.jar:9.2.1.v20140609]
        at org.eclipse.jetty.server.handler.ErrorHandler.handle(ErrorHandler.java:91) [jetty-server-9.2.1.v20140609.jar:9.2.1.v20140609]
        at org.eclipse.jetty.server.Response.sendError(Response.java:589) [jetty-server-9.2.1.v20140609.jar:9.2.1.v20140609]
        at org.eclipse.jetty.server.Response.sendError(Response.java:547) [jetty-server-9.2.1.v20140609.jar:9.2.1.v20140609]
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:626) [jetty-servlet-9.2.1.v20140609.jar:9.2.1.v20140609]
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) [jetty-server-9.2.1.v20140609.jar:9.2.1.v20140609]
        at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:554) [jetty-security-9.2.1.v20140609.jar:9.2.1.v20140609]
        at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:221) [jetty-server-9.2.1.v20140609.jar:9.2.1.v20140609]
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1111) [jetty-server-9.2.1.v20140609.jar:9.2.1.v20140609]
        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:498) [jetty-servlet-9.2.1.v20140609.jar:9.2.1.v20140609]
        at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:183) [jetty-server-9.2.1.v20140609.jar:9.2.1.v20140609]
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1045) [jetty-server-9.2.1.v20140609.jar:9.2.1.v20140609]
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [jetty-server-9.2.1.v20140609.jar:9.2.1.v20140609]
        at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:199) [jetty-server-9.2.1.v20140609.jar:9.2.1.v20140609]
        at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:109) [jetty-server-9.2.1.v20140609.jar:9.2.1.v20140609]
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:98) [jetty-server-9.2.1.v20140609.jar:9.2.1.v20140609]
        at org.eclipse.jetty.server.Server.handle(Server.java:461) [jetty-server-9.2.1.v20140609.jar:9.2.1.v20140609]
        at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:284) [jetty-server-9.2.1.v20140609.jar:9.2.1.v20140609]
        at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:244) [jetty-server-9.2.1.v20140609.jar:9.2.1.v20140609]
        at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:534) [jetty-io-9.2.1.v20140609.jar:9.2.1.v20140609]
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:607) [jetty-util-9.2.1.v20140609.jar:9.2.1.v20140609]
        at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:536) [jetty-util-9.2.1.v20140609.jar:9.2.1.v20140609]
        at java.lang.Thread.run(Thread.java:745) [na:1.7.0_60]

Note that the exception complains about an address (http://my-host/my-app/) different from the called one (http://my-host/my-app/togglz/edit), as if a redirect or forward is in place.

Analising Togglz source code, specially the EditPageHandler class, when POST is successed there is in deed a sendRedirect() call, but it should ends by returning 302 status code and redirecting to /togglz/index URI.

I wasn't able to find where a 404 could take place, and I'm not able to debug it since the issue only occurs in the production environment (in dev environment it is just fine, and I have already checked Jetty versions and they are the same).

Anyone has any light on this matter?

Thanks in advance.


Solution

  • After some struggle I found out the cause of the problem!

    Togglz was not able to write in the .properties file where the features are (missing privileges).

    Now, don't ask me why FeatureConsoleServlet didn't log the original exception and why it causes a forward to the root URI. (If any one has the answer to this, feel free to edit this answer).