0

我在带有 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/togglz/edit )不同的地址 ( http://my-host/my-app/ ),就像重定向或前锋就位。

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

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

有人对这件事有任何了解吗?

提前致谢。

4

1 回答 1

0

经过一番挣扎,我找到了问题的原因!

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

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

于 2015-05-22T18:22:27.703 回答