Netty producing exception when server is killed
See original GitHub issueExpected behavior
I have used to following code to handle server shutdown:
public void stop() {
try {
this.channelFuture.channel().close();
this.channelFuture.channel().closeFuture().sync();
} catch (InterruptedException e) {
Log.exceptionStack(e);
} finally {
this.bootstrap.config().childGroup().shutdownGracefully(10, 30, TimeUnit.SECONDS);
this.bootstrap.config().group().shutdownGracefully(5, 10, TimeUnit.SECONDS);
}
}
It should shutdown without any exceptions
Actual behavior
Sometimes the server shutsdown with the following exception:
Exception in thread "nioEventLoopGroup-3-1" java.lang.NoClassDefFoundError: io/netty/buffer/PoolArena$1
at io.netty.buffer.PoolArena.freeChunk(PoolArena.java:293)
at io.netty.buffer.PoolThreadCache$MemoryRegionCache.freeEntry(PoolThreadCache.java:471)
at io.netty.buffer.PoolThreadCache$MemoryRegionCache.free(PoolThreadCache.java:441)
at io.netty.buffer.PoolThreadCache$MemoryRegionCache.free(PoolThreadCache.java:433)
at io.netty.buffer.PoolThreadCache.free(PoolThreadCache.java:290)
at io.netty.buffer.PoolThreadCache.free(PoolThreadCache.java:281)
at io.netty.buffer.PoolThreadCache.free0(PoolThreadCache.java:254)
at io.netty.buffer.PoolThreadCache.free(PoolThreadCache.java:250)
at io.netty.buffer.PooledByteBufAllocator$PoolThreadLocalCache.onRemoval(PooledByteBufAllocator.java:431)
at io.netty.buffer.PooledByteBufAllocator$PoolThreadLocalCache.onRemoval(PooledByteBufAllocator.java:408)
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: io.netty.buffer.PoolArena$1
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 14 more
Exception in thread "Thread-1" java.lang.NoClassDefFoundError: io/netty/channel/AbstractChannelHandlerContext$13
at io.netty.channel.AbstractChannelHandlerContext.close(AbstractChannelHandlerContext.java:610)
at io.netty.channel.AbstractChannelHandlerContext.close(AbstractChannelHandlerContext.java:465)
at io.netty.channel.DefaultChannelPipeline.close(DefaultChannelPipeline.java:964)
at io.netty.channel.AbstractChannel.close(AbstractChannel.java:234)
at co.iotfy.gps.smaartly.TrackerServer.stop(TrackerServer.java:59)
at co.iotfy.gps.smaartly.ServerManager.stop(ServerManager.java:90)
at co.iotfy.gps.smaartly.App$1.run(App.java:22)
Caused by: java.lang.ClassNotFoundException: io.netty.channel.AbstractChannelHandlerContext$13
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more
Netty version
4.1.9.Final
JVM version (e.g. java -version
)
java version “1.8.0_121” Java™ SE Runtime Environment (build 1.8.0_121-b13) Java HotSpot™ 64-Bit Server VM (build 25.121-b13, mixed mode)
OS version (e.g. uname -a
)
4.8.0-44-generic #47~16.04.1-Ubuntu
Let me know if any other information is required.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:20 (12 by maintainers)
Top Results From Across the Web
Netty server shutdown exception - java - Stack Overflow
Sometimes the server shutsdown with the following exception: ... freeEntry(PoolThreadCache.java:471) at io.netty.buffer.
Read more >reactor/reactor-netty - Gitter
How do we kill/dispose the netty channel if there is an exception in connecting to server. Eg, Service A is using reactor netty...
Read more >Karate Netty
Server -Side Karate. A perfect match ! It is worth calling out why Karate on the 'other side of the fence' (handling HTTP...
Read more >Management & Monitoring - Micronaut Documentation
It is possible to stop the Netty server without stopping the Application context. You can declare beans at runtime using interfaces. You can...
Read more >io.netty Exception when trying to run Spigot for the first time.
Hello everyone! I'm a noobie at these forums AND at making Minecraft servers. I had just downloaded Spigot server for 1.14.4 from (redacted) ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@sshntt can you provide a full listing of the Netty jars on your classpath? It sounds as though you may have multiple versions which are not binary compatible. Consider checking out the netty-bom artifact.
@jamesdbloom yeah… I am not sure what exactly is causing it but it seems like it is a result of the class loader to already unloading stuff while we still use it.