{"action":"created","issue":{"url":"https://api.github.com/repos/alibaba/dubbo/issues/333","repository_url":"https://api.github.com/repos/alibaba/dubbo","labels_url":"https://api.github.com/repos/alibaba/dubbo/issues/333/labels{/name}","comments_url":"https://api.github.com/repos/alibaba/dubbo/issues/333/comments","events_url":"https://api.github.com/repos/alibaba/dubbo/issues/333/events","html_url":"https://github.com/alibaba/dubbo/issues/333","id":183603912,"number":333,"title":"重启tomcat的时候DubboShutdownHook会报一个非常讨厌的WARN","user":{"login":"jiakai0419","id":5144903,"avatar_url":"https://avatars.githubusercontent.com/u/5144903?v=3","gravatar_id":"","url":"https://api.github.com/users/jiakai0419","html_url":"https://github.com/jiakai0419","followers_url":"https://api.github.com/users/jiakai0419/followers","following_url":"https://api.github.com/users/jiakai0419/following{/other_user}","gists_url":"https://api.github.com/users/jiakai0419/gists{/gist_id}","starred_url":"https://api.github.com/users/jiakai0419/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jiakai0419/subscriptions","organizations_url":"https://api.github.com/users/jiakai0419/orgs","repos_url":"https://api.github.com/users/jiakai0419/repos","events_url":"https://api.github.com/users/jiakai0419/events{/privacy}","received_events_url":"https://api.github.com/users/jiakai0419/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2016-10-18T06:51:45Z","updated_at":"2016-10-21T12:59:45Z","closed_at":"2016-10-21T12:40:48Z","body":"### 现象\r\n每当我重启tomcat的时候，就会报下面的warning。\r\n```\r\n2016-10-18 14:30:09.470  INFO DubboShutdownHook ZookeeperRegistry:485 -  [DUBBO] Destroy registry:zookeeper://172.21.134.7:2005/com.alibaba.dubbo.registry.RegistryService?application=stormsun&dubbo=2.8.4&interface=com.alibaba.dubbo.registry.RegistryService&owner=kaijia&pid=868&timestamp=1476760120506, dubbo version: 2.8.4, current host: 127.0.0.1\r\n2016-10-18 14:30:09.471  WARN DubboShutdownHook ZookeeperRegistry:440 -  [DUBBO] java/util/concurrent/ScheduledFuture, dubbo version: 2.8.4, current host: 127.0.0.1\r\njava.lang.NoClassDefFoundError: java/util/concurrent/ScheduledFuture\r\n\tat com.alibaba.dubbo.registry.support.FailbackRegistry.destroy(FailbackRegistry.java:438)\r\n\tat com.alibaba.dubbo.registry.zookeeper.ZookeeperRegistry.destroy(ZookeeperRegistry.java:88)\r\n\tat com.alibaba.dubbo.registry.support.AbstractRegistryFactory.destroyAll(AbstractRegistryFactory.java:70)\r\n\tat com.alibaba.dubbo.config.ProtocolConfig.destroyAll(ProtocolConfig.java:463)\r\n\tat com.alibaba.dubbo.config.AbstractConfig$1.run(AbstractConfig.java:452)\r\n\tat java.lang.Thread.run(Thread.java:745)\r\nCaused by: java.lang.ClassNotFoundException: Illegal access: this web application instance has been stopped already. Could not load [java.util.concurrent.ScheduledFuture]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.\r\n\tat org.apache.catalina.loader.WebappClassLoaderBase.checkStateForClassLoading(WebappClassLoaderBase.java:1315)\r\n\tat org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1178)\r\n\tat org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1139)\r\n\t... 6 more\r\nCaused by: java.lang.IllegalStateException: Illegal access: this web application instance has been stopped already. Could not load [java.util.concurrent.ScheduledFuture]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.\r\n\tat org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading(WebappClassLoaderBase.java:1325)\r\n\tat org.apache.catalina.loader.WebappClassLoaderBase.checkStateForClassLoading(WebappClassLoaderBase.java:1313)\r\n\t... 8 more\r\n2016-10-18 14:30:09.471  INFO ZkClient-EventThread-29-172.21.134.7:2005 ZkEventThread:82 - Terminate ZkClient event thread.\r\n2016-10-18 14:30:09.476  INFO localhost-startStop-1-EventThread ClientCnxn:516 - EventThread shut down\r\n2016-10-18 14:30:09.476  INFO DubboShutdownHook ZooKeeper:544 - Session: 0x157bc04550c0142 closed\r\n2016-10-18 14:30:09.477  INFO DubboShutdownHook DubboProtocol:439 -  [DUBBO] Close dubbo server: /172.21.134.7:20883, dubbo version: 2.8.4, current host: 127.0.0.1\r\n2016-10-18 14:30:09.479  WARN DubboShutdownHook HeaderExchangeServer:255 -  [DUBBO] java/util/concurrent/ScheduledFuture, dubbo version: 2.8.4, current host: 127.0.0.1\r\njava.lang.NoClassDefFoundError: java/util/concurrent/ScheduledFuture\r\n\tat com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeServer.stopHeartbeatTimer(HeaderExchangeServer.java:251)\r\n\tat com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeServer.doClose(HeaderExchangeServer.java:145)\r\n\tat com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeServer.close(HeaderExchangeServer.java:120)\r\n\tat com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol.destroy(DubboProtocol.java:441)\r\n\tat com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper.destroy(ProtocolFilterWrapper.java:66)\r\n\tat com.alibaba.dubbo.rpc.protocol.ProtocolListenerWrapper.destroy(ProtocolListenerWrapper.java:72)\r\n\tat com.alibaba.dubbo.config.ProtocolConfig.destroyAll(ProtocolConfig.java:469)\r\n\tat com.alibaba.dubbo.config.AbstractConfig$1.run(AbstractConfig.java:452)\r\n\tat java.lang.Thread.run(Thread.java:745)\r\nCaused by: java.lang.ClassNotFoundException: Illegal access: this web application instance has been stopped already. Could not load [java.util.concurrent.ScheduledFuture]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.\r\n\tat org.apache.catalina.loader.WebappClassLoaderBase.checkStateForClassLoading(WebappClassLoaderBase.java:1315)\r\n\tat org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1178)\r\n\tat org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1139)\r\n\t... 9 more\r\nCaused by: java.lang.IllegalStateException: Illegal access: this web application instance has been stopped already. Could not load [java.util.concurrent.ScheduledFuture]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.\r\n\tat org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading(WebappClassLoaderBase.java:1325)\r\n\tat org.apache.catalina.loader.WebappClassLoaderBase.checkStateForClassLoading(WebappClassLoaderBase.java:1313)\r\n\t... 11 more\r\n2016-10-18 14:30:09.487  INFO DubboShutdownHook AbstractServer:147 -  [DUBBO] Close NettyServer bind /0.0.0.0:20883, export /172.21.134.7:20883, dubbo version: 2.8.4, current host: 127.0.0.1\r\n2016-10-18 14:30:09.495  WARN DubboShutdownHook NettyServer:127 -  [DUBBO] org/jboss/netty/util/internal/ExecutorUtil, dubbo version: 2.8.4, current host: 127.0.0.1\r\njava.lang.NoClassDefFoundError: org/jboss/netty/util/internal/ExecutorUtil\r\n\tat org.jboss.netty.channel.socket.nio.AbstractNioBossPool.releaseExternalResources(AbstractNioBossPool.java:91)\r\n\tat org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory.releasePools(NioServerSocketChannelFactory.java:223)\r\n\tat org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory.releaseExternalResources(NioServerSocketChannelFactory.java:218)\r\n\tat org.jboss.netty.bootstrap.Bootstrap.releaseExternalResources(Bootstrap.java:318)\r\n\tat com.alibaba.dubbo.remoting.transport.netty.NettyServer.doClose(NettyServer.java:124)\r\n\tat com.alibaba.dubbo.remoting.transport.AbstractServer.close(AbstractServer.java:156)\r\n\tat com.alibaba.dubbo.remoting.transport.AbstractServer.close(AbstractServer.java:164)\r\n\tat com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeServer.close(HeaderExchangeServer.java:121)\r\n\tat com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol.destroy(DubboProtocol.java:441)\r\n\tat com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper.destroy(ProtocolFilterWrapper.java:66)\r\n\tat com.alibaba.dubbo.rpc.protocol.ProtocolListenerWrapper.destroy(ProtocolListenerWrapper.java:72)\r\n\tat com.alibaba.dubbo.config.ProtocolConfig.destroyAll(ProtocolConfig.java:469)\r\n\tat com.alibaba.dubbo.config.AbstractConfig$1.run(AbstractConfig.java:452)\r\n\tat java.lang.Thread.run(Thread.java:745)\r\nCaused by: java.lang.ClassNotFoundException: Illegal access: this web application instance has been stopped already. Could not load [org.jboss.netty.util.internal.ExecutorUtil]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.\r\n\tat org.apache.catalina.loader.WebappClassLoaderBase.checkStateForClassLoading(WebappClassLoaderBase.java:1315)\r\n\tat org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1178)\r\n\tat org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1139)\r\n\t... 14 more\r\nCaused by: java.lang.IllegalStateException: Illegal access: this web application instance has been stopped already. Could not load [org.jboss.netty.util.internal.ExecutorUtil]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.\r\n\tat org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading(WebappClassLoaderBase.java:1325)\r\n\tat org.apache.catalina.loader.WebappClassLoaderBase.checkStateForClassLoading(WebappClassLoaderBase.java:1313)\r\n\t... 16 more\r\n2016-10-18 14:30:13.291  INFO localhost-startStop-1 ContextLoader:307 - Root WebApplicationContext: initialization started\r\n```\r\n\r\n### 猜测和目标\r\n看起来像dubbo执行shutdown hook的时候，web application已经停掉了。\r\n我这个强迫症看这个warning特别难受，在tomcat重启的时候我怎样才能**优雅的关闭dubbo，消除掉这个warning**。\r\n\r\n### 环境\r\n编译方式\r\n```\r\n            <plugin>\r\n                <groupId>org.apache.maven.plugins</groupId>\r\n                <artifactId>maven-compiler-plugin</artifactId>\r\n                <version>2.5.1</version>\r\n                <configuration>\r\n                    <source>1.8</source>\r\n                    <target>1.8</target>\r\n                    <encoding>UTF-8</encoding>\r\n                </configuration>\r\n            </plugin>\r\n```\r\nJRE\r\n```\r\njava version \"1.8.0_11\"\r\nJava(TM) SE Runtime Environment (build 1.8.0_11-b12)\r\nJava HotSpot(TM) 64-Bit Server VM (build 25.11-b03, mixed mode)\r\n```\r\nTomcat\r\n`Apache Tomcat Version 8.0.33`"},"comment":{"url":"https://api.github.com/repos/alibaba/dubbo/issues/comments/255370897","html_url":"https://github.com/alibaba/dubbo/issues/333#issuecomment-255370897","issue_url":"https://api.github.com/repos/alibaba/dubbo/issues/333","id":255370897,"user":{"login":"wuwen5","id":5037807,"avatar_url":"https://avatars.githubusercontent.com/u/5037807?v=3","gravatar_id":"","url":"https://api.github.com/users/wuwen5","html_url":"https://github.com/wuwen5","followers_url":"https://api.github.com/users/wuwen5/followers","following_url":"https://api.github.com/users/wuwen5/following{/other_user}","gists_url":"https://api.github.com/users/wuwen5/gists{/gist_id}","starred_url":"https://api.github.com/users/wuwen5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wuwen5/subscriptions","organizations_url":"https://api.github.com/users/wuwen5/orgs","repos_url":"https://api.github.com/users/wuwen5/repos","events_url":"https://api.github.com/users/wuwen5/events{/privacy}","received_events_url":"https://api.github.com/users/wuwen5/received_events","type":"User","site_admin":false},"created_at":"2016-10-21T12:59:45Z","updated_at":"2016-10-21T12:59:45Z","body":"```@PreDestroy```会在spring 容器destroy处理开始之前执行，你的redis连接池应该是由spring容器管理，spring容器会有序销毁资源。\r\n"}}
{"actor":{"display_login":"wuwen5"}}