{"id":1886,"date":"2022-08-30T15:20:16","date_gmt":"2022-08-30T15:20:16","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/12\/02\/netty-3-5-8-final-exception-in-thread-closed-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:20:16","modified_gmt":"2022-08-30T15:20:16","slug":"netty-3-5-8-final-exception-in-thread-closed-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/netty-3-5-8-final-exception-in-thread-closed-collection-of-common-programming-errors\/","title":{"rendered":"Netty 3.5.8.Final Exception in thread [closed]-Collection of common programming errors"},"content":{"rendered":"<p>Several times a minute there is an error<\/p>\n<pre><code>channelConnected\nException in thread \"pool-632-thread-1\" java.lang.NoClassDefFoundError: Could not initialize class org.jboss.netty.util.internal.DetectionUtil\n    at org.jboss.netty.util.HashedWheelTimer$Worker.waitForNextTick(HashedWheelTimer.java:456)\n    at org.jboss.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:373)\n    at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:102)\n    at java.lang.Thread.run(Unknown Source)\n<\/code><\/pre>\n<p>Netty 3.5.8.Final. How to fix it? I&#8217;m using Netty 3.5.3 and the error disappears, but there is a memory leak. Here is the code that I use. The error occurs when channelConnected:<\/p>\n<pre><code>public class Netty {\n    private ClientBootstrap Cbootstrap = new ClientBootstrap(new NioClientSocketChannelFactory( Executors.newCachedThreadPool(), Executors.newCachedThreadPool()));\n    private ServerBootstrap Sbootstrap = new ServerBootstrap(new NioServerSocketChannelFactory( Executors.newCachedThreadPool(), Executors.newCachedThreadPool()));    \n    public Netty(int port) {\n        final Handler Handler = new Handler();\n        ChannelPipelineFactory CPF = new ChannelPipelineFactory() {\n            public ChannelPipeline getPipeline() {\n                return Channels.pipeline(new ReadTimeoutHandler(new HashedWheelTimer(), 30), Handler);\n            }\n    };\n    Cbootstrap.setPipelineFactory(CPF);\n        Sbootstrap.setPipelineFactory(CPF);\n        Cbootstrap.setOption(\"connectTimeoutMillis\", 5000);\n        Sbootstrap.setOption(\"connectTimeoutMillis\", 5000);\n    Cbootstrap.setOption(\"tcpNoDelay\", true);\n    Cbootstrap.setOption(\"keepAlive\", true);\n        Sbootstrap.setOption(\"child.tcpNoDelay\", true);\n        Sbootstrap.setOption(\"child.keepAlive\", true);\n        Sbootstrap.bind(new InetSocketAddress(port));   \n    }\n    public void connect(InetAddress addr, int port) {\n        Cbootstrap.connect(new InetSocketAddress(addr, port));\n    }\n}\n<\/code><\/pre>\n<pre><code>public class Handler extends SimpleChannelHandler {\n    @Override\n    public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) {\n        ChannelBuffer buf = (ChannelBuffer) e.getMessage();\n        System.out.println(buf.toString(\"windows-1251\"));\n        Channel ch = e.getChannel();\n        ChannelBuffer buff = ChannelBuffers.dynamicBuffer();\n    buff.writeBytes((\"TEST1\").getBytes());\n        ch.write(buff);\n    }\n    @Override\n    public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) {\n        ChannelBuffer buf = (ChannelBuffer) e.getMessage();\n        System.out.println(buf.toString(\"windows-1251\"));\n        Channel ch = e.getChannel();\n        ChannelBuffer buff = ChannelBuffers.dynamicBuffer();\n    buff.writeBytes((\"TEST2\").getBytes());\n        ch.write(buff);\n    }\n}\n<\/code><\/pre>\n<ol>\n<li>\n<p>That&#8217;s strange.. Is it possible that you have two versions of Netty on the classpath ? Like the old 3.5.3.FInal and the new 3.5.8.Final ?<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-12-02 21:11:23. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>Several times a minute there is an error channelConnected Exception in thread &#8220;pool-632-thread-1&#8221; java.lang.NoClassDefFoundError: Could not initialize class org.jboss.netty.util.internal.DetectionUtil at org.jboss.netty.util.HashedWheelTimer$Worker.waitForNextTick(HashedWheelTimer.java:456) at org.jboss.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:373) at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:102) at java.lang.Thread.run(Unknown Source) Netty 3.5.8.Final. How to fix it? I&#8217;m using Netty 3.5.3 and the error disappears, but there is a memory leak. Here is the code that I use. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1886","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1886","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1886"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1886\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1886"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1886"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1886"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}