弹簧启动执行器 - " / shutdown"失败,出现500错误

时间:2016-01-27 15:06:39

标签: java spring web-applications spring-boot actuator

背景资料

我有一个使用Actuator的Spring Boot Web应用程序用于生产实用程序。

应用程序运行正常,管理端口运行良好。我可以浏览统计信息,检查运行状况等。我还启用了远程关闭端点,它正确显示在localhost:{mgmt_port} /执行器端点列表中。

我的问题

当我去localhost:{mgmt_port} / shutdown时,我看到了:

<Map>
    <timestamp>1453905900007</timestamp>
    <status>500</status>
    <error>Internal Server Error</error>
    <exception>org.springframework.web.HttpRequestMethodNotSupportedException</exception>
    <message>Request method 'GET' not supported</message>
    <path>/shutdown</path>
</Map>

实用信息

  • 点击关闭链接后,整个应用程序似乎仍在运行。我仍然可以从自定义应用程序端点提取数据。

  • Spring执行器提供的管理URL在关闭后似乎仍然运行良好。

发布前的控制台输出

  

10:01:42.496 [main] INFO o.s.b.c.e.t.TomcatEmbeddedServletContainer -   Tomcat从端口开始:8002(http)10:01:42.499 [main] INFO   com.xyz.api.Main - 在5.956秒内启动Main(JVM   运行6.381)

发布后

控制台输出

  

10:03:29.090 [http-nio-8003-exec-1] INFO   o.a.c.c.C. [Tomcat-1]。[localhost]。[/] - 初始化Spring   FrameworkServlet&#39; dispatcherServlet&#39; 10:03:29.090   [http-nio-8003-exec-1] INFO o.s.web.servlet.DispatcherServlet -   FrameworkServlet&#39; dispatcherServlet&#39;:初始化已启动   10:03:29.126 [http-nio-8003-exec-1] INFO   o.s.web.servlet.DispatcherServlet - FrameworkServlet   &#39; dispatcherServlet&#39;:初始化在36毫秒10:03:29.151完成   [http-nio-8003-exec-1] ERROR o.a.c.c.C。[。[。[。[dispatcherServlet] -   servlet [dispatcherServlet]的Servlet.service()与path一起使用   []抛出异常[请求方法&#39; GET&#39;不支持]用root   导致org.springframework.web.HttpRequestMethodNotSupportedException:   请求方法&#39; GET&#39;不支持           在org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping.handleNoMatch(RequestMappingInfoHandlerMapping.java:204)   〜[弹簧webmvc-4.2.4.RELEASE.jar /:4.2.4.RELEASE]           在org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.lookupHandlerMethod(AbstractHandlerMethodMapping.java:382)   〜[弹簧webmvc-4.2.4.RELEASE.jar /:4.2.4.RELEASE]           在org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:322)   〜[弹簧webmvc-4.2.4.RELEASE.jar /:4.2.4.RELEASE]           在org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:60)   〜[弹簧webmvc-4.2.4.RELEASE.jar /:4.2.4.RELEASE]           在org.springframework.web.servlet.handler.AbstractHandlerMapping.getHandler(AbstractHandlerMapping.java:351)   〜[弹簧webmvc-4.2.4.RELEASE.jar /:4.2.4.RELEASE]           at org.springframework.boot.actuate.autoconfigure.EndpointWebMvcChildContextConfiguration $ CompositeHandlerMapping.getHandler(EndpointWebMvcChildContextConfiguration.java:212)   〜[春季启动制动器 - 1.3.2.RELEASE.jar /:1.3.2.RELEASE]           在org.springframework.web.servlet.DispatcherServlet.getHandler(DispatcherServlet.java:1120)   〜[弹簧webmvc-4.2.4.RELEASE.jar /:4.2.4.RELEASE]           在org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:932)   〜[弹簧webmvc-4.2.4.RELEASE.jar /:4.2.4.RELEASE]           在org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)   〜[弹簧webmvc-4.2.4.RELEASE.jar /:4.2.4.RELEASE]           在org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:969)   〜[弹簧webmvc-4.2.4.RELEASE.jar /:4.2.4.RELEASE]           在org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:860)   〜[弹簧webmvc-4.2.4.RELEASE.jar /:4.2.4.RELEASE]           在javax.servlet.http.HttpServlet.service(HttpServlet.java:622)   [!Tomcat的嵌入芯-8.0.30.jar /:8.0.30]〜           在org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:845)   〜[弹簧webmvc-4.2.4.RELEASE.jar /:4.2.4.RELEASE]           在javax.servlet.http.HttpServlet.service(HttpServlet.java:729)   [!Tomcat的嵌入芯-8.0.30.jar /:8.0.30]〜           在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)   [!Tomcat的嵌入芯-8.0.30.jar /:8.0.30]〜           在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)   [!Tomcat的嵌入芯-8.0.30.jar /:8.0.30]〜           在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)   [!Tomcat的嵌入芯-8.0.30.jar /:8.0.30]〜           在org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)   [Tomcat的嵌入核心-8.0.30.jar /:8.0.30]           在org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)   [Tomcat的嵌入核心-8.0.30.jar /:8.0.30]           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)   [Tomcat的嵌入核心-8.0.30.jar /:8.0.30]           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)   [Tomcat的嵌入核心-8.0.30.jar /:8.0.30]           在org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)   [Tomcat的嵌入核心-8.0.30.jar /:8.0.30]           在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:521)   [Tomcat的嵌入核心-8.0.30.jar /:8.0.30]           在org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1096)   [Tomcat的嵌入核心-8.0.30.jar /:8.0.30]           at org.apache.coyote.AbstractProtocol $ AbstractConnectionHandler.process(AbstractProtocol.java:674)   [Tomcat的嵌入核心-8.0.30.jar /:8.0.30]           在org.apache.tomcat.util.net.NioEndpoint $ SocketProcessor.doRun(NioEndpoint.java:1500)   [Tomcat的嵌入核心-8.0.30.jar /:8.0.30]           在org.apache.tomcat.util.net.NioEndpoint $ SocketProcessor.run(NioEndpoint.java:1456)   [Tomcat的嵌入核心-8.0.30.jar /:8.0.30]           at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)[na:1.8.0_51]           at java.util.concurrent.ThreadPoolExecutor $ Worker.run(Unknown Source)[na:1.8.0_51]           at org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run(TaskThread.java:61)   [Tomcat的嵌入核心-8.0.30.jar /:8.0.30]           在java.lang.Thread.run(未知来源)[na:1.8.0_51]

1 个答案:

答案 0 :(得分:3)

回答我自己的问题,以便将来帮助他人。我是个笨蛋...... /actuator网址列出了所有可用的命令,所有这些命令都基于GET请求工作。

/shutdown网址实际上需要HTTP POST发送给它才能激活它。我没有在文档中的任何地方看到这一点。

示例CURL命令:

> curl -X POST http://hostname:8003/shutdown

关闭命令的输出:

<SingletonMap><message>Shutting down, bye...</message></SingletonMap>