通过Togglz管理控制台编辑功能时出现错误404

时间:2015-05-21 13:34:07

标签: java spring jetty togglz

我在使用Spring 4.0.5.RELEASE和Jetty 9.2.1.v20140609的Web应用程序中使用Togglz 2.0.1.Final。

当我尝试使用Togglz管理控制台编辑功能时,POST请求会收到404状态代码。

请求标题

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

申请表格数据

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

响应标题

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

在服务器端,抛出以下异常:

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]

请注意,该异常会抱怨与被叫方(http://my-host/my-app/)不同的地址(http://my-host/my-app/togglz/edit),就像重定向或转发一样。

Analising Togglz源代码,特别是EditPageHandler类,当POST成功时,会有一个sendRedirect()调用,但它应该以返回302状态代码并重定向到/ togglz / index URI结束。

我无法找到404可能发生的地方,而且我无法调试它,因为问题只发生在生产环境中(在开发环境中它很好,我已经检查过Jetty了)版本和它们是相同的。)

任何人都对此事有任何了解?

提前致谢。

1 个答案:

答案 0 :(得分:0)

经过一番努力,我发现了问题的原因!

Togglz无法在功能所在的.properties文件中写入(缺少权限)。

现在,不要问我为什么FeatureConsoleServlet没有记录原始异常以及它导致转发到根URI的原因。 (如果有人对此有答案,请随时编辑此答案。)