java一个函数等待另一个函数_Tomcat停止前等待某个函数运行结束的问题

在编写java ee应用的时候,在一个Servlet里的的初始化(init)里启动了一个多线程(用netty写的进行socket通信的),在Servlet里的销毁(destory)里手动显示的关闭netty的线程,但是却报如下错误,请问该怎么解决?

09-Jan-2017 14:24:07.384 严重 [localhost-startStop-1] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [electric] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@637604d1]) and a value of type [io.netty.util.internal.InternalThreadLocalMap] (value [io.netty.util.internal.InternalThreadLocalMap@6c896b26]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.

09-Jan-2017 14:24:07.393 信息 [main] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["http-nio-8080"]

09-Jan-2017 14:24:07.393 信息 [main] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["ajp-nio-8009"]

09-Jan-2017 14:24:07.393 信息 [main] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["http-nio-8080"]

09-Jan-2017 14:24:07.394 信息 [main] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["ajp-nio-8009"]

09-Jan-2017 14:24:09.468 信息 [nioEventLoopGroup-3-1] org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading Illegal access: this web application instance has been stopped already. Could not load [io.netty.buffer.PoolArena$1]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.

java.lang.IllegalStateException: Illegal access: this web application instance has been stopped already. Could not load [io.netty.buffer.PoolArena$1]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.

at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading(WebappClassLoaderBase.java:1295)

at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForClassLoading(WebappClassLoaderBase.java:1283)

at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1148)

at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1109)

at io.netty.buffer.PoolArena.freeChunk(PoolArena.java:279)

at io.netty.buffer.PoolThreadCache$MemoryRegionCache.freeEntry(PoolThreadCache.java:456)

at io.netty.buffer.PoolThreadCache$MemoryRegionCache.free(PoolThreadCache.java:426)

at io.netty.buffer.PoolThreadCache$MemoryRegionCache.free(PoolThreadCache.java:418)

at io.netty.buffer.PoolThreadCache.free(PoolThreadCache.java:275)

at io.netty.buffer.PoolThreadCache.free(PoolThreadCache.java:266)

at io.netty.buffer.PoolThreadCache.free0(PoolThreadCache.java:239)

at io.netty.buffer.PoolThreadCache.free(PoolThreadCache.java:235)

at io.netty.buffer.PooledByteBufAllocator$PoolThreadLocalCache.onRemoval(PooledByteBufAllocator.java:359)

at io.netty.buffer.PooledByteBufAllocator$PoolThreadLocalCache.onRemoval(PooledByteBufAllocator.java:345)

at io.netty.util.concurrent.FastThreadLocal.remove(FastThreadLocal.java:226)

at io.netty.util.concurrent.FastThreadLocal.removeAll(FastThreadLocal.java:67)

at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:146)

at java.lang.Thread.run(Thread.java:745)

Exception in thread "nioEventLoopGroup-3-1" java.lang.NoClassDefFoundError: io/netty/buffer/PoolArena$1

at io.netty.buffer.PoolArena.freeChunk(PoolArena.java:279)

at io.netty.buffer.PoolThreadCache$MemoryRegionCache.freeEntry(PoolThreadCache.java:456)

at io.netty.buffer.PoolThreadCache$MemoryRegionCache.free(PoolThreadCache.java:426)

at io.netty.buffer.PoolThreadCache$MemoryRegionCache.free(PoolThreadCache.java:418)

at io.netty.buffer.PoolThreadCache.free(PoolThreadCache.java:275)

at io.netty.buffer.PoolThreadCache.free(PoolThreadCache.java:266)

at io.netty.buffer.PoolThreadCache.free0(PoolThreadCache.java:239)

at io.netty.buffer.PoolThreadCache.free(PoolThreadCache.java:235)

at io.netty.buffer.PooledByteBufAllocator$PoolThreadLocalCache.onRemoval(PooledByteBufAllocator.java:359)

at io.netty.buffer.PooledByteBufAllocator$PoolThreadLocalCache.onRemoval(PooledByteBufAllocator.java:345)

at io.netty.util.concurrent.FastThreadLocal.remove(FastThreadLocal.java:226)

at io.netty.util.concurrent.FastThreadLocal.removeAll(FastThreadLocal.java:67)

at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:146)

at java.lang.Thread.run(Thread.java:745)

Caused by: java.lang.ClassNotFoundException: Illegal access: this web application instance has been stopped already. Could not load [io.netty.buffer.PoolArena$1]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.

at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForClassLoading(WebappClassLoaderBase.java:1285)

at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1148)

at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1109)

... 14 more

Caused by: java.lang.IllegalStateException: Illegal access: this web application instance has been stopped already. Could not load [io.netty.buffer.PoolArena$1]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.

at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading(WebappClassLoaderBase.java:1295)

at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForClassLoading(WebappClassLoaderBase.java:1283)

... 16 more

Disconnected from server

tomcat 版本是 tomcat9=m14,netty用的netty-all 4.1.5.

请问该如何解决呢?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值