is not a @Sharable handler解决方法
来源:互联网 发布:安祖赛弗的数据1 编辑:程序博客网 时间:2024/05/01 19:48
昨天在写编码器的时候,因为是和spring整合,因此在使用编码的时候用Autowired自动注入
@Autowiredprivate ProtocolDecoder protocolDecoder ;@Autowiredprivate ProtocolEncoder protocolEncoder;
结果在多个客户端连接(其实不是多客户端的问题)的时候导致一直在报错,如下
io.netty.channel.ChannelPipelineException: com.sim.server.game.net.coder.decoder.ProtocolDecoder is not a @Sharable handler, so can't be added or removed multiple times.
于是我就自作聪明的将ProtocolDecoder上加了个@Sharable注解,结果在启动的时候就报错了。
Caused by: java.lang.IllegalStateException: ChannelHandler com.sim.server.game.net.coder.decoder.ProtocolDecoder is not allowed to be shared
最后的解决方法是,不要使用单例了,每次添加handler的时候直接new
pipeline.addLast("decoder",new ProtocolDecoder() ); pipeline.addLast("encoder",new ProtocolEncoder()) ;
当然如果是在ChannelInitializer的子类报错说is not a @Sharable handler,一般情况加上@Sharable注解即可。
阅读全文
0 0
- is not a @Sharable handler解决方法
- rvm is not a function的解决方法
- file is not a zip file 解决方法
- TYPEERROR: UNDEFINED IS NOT A FUNCTION解决方法
- Netty Sharable Handler 使用是私有变量
- is not a class or namespace name解决方法
- 应用程序"is not a valid Pocket PC Application"的解决方法
- js报错:****is not a function 的解决方法
- ldconfig提示“is not a symbolic link”的解决方法
- svn is not a working copy directory 的解决方法
- Uncaught TypeError: object is not a function的解决方法
- is not a class or namespace name解决方法
- is not a class or namespace name解决方法
- /lib64/libc.so.6 is not a symbolic link 解决方法
- intermediate value is not a function报错解决方法
- js报$ is not a function 的问题的解决方法
- ajaxFileUpload报错$.ajaxFileUpload is not a function解决方法
- ajaxFileUpload :jQuery.handleError is not a function的解决方法
- typedef
- My97DatePicker日期控件展示时默认时间不为该控件可用最小时间
- 集合中HashMap,HashTable,HashSet的区别?
- Eclipse的使用
- Python代码规范和命名规范
- is not a @Sharable handler解决方法
- Maven系列--"maven-source-plugin"的使用
- JSP的EL表达式中默认数据域及取值方式
- Maven项目创建注意事项
- 解决Android中No resource found that matches android:TextAppearance.Material.Widget.Button.Inverse问题
- MYSQL 5.7 压缩版环境配置小计
- Django---ORM总结
- 设计模式
- 常用的 Eclipse 开发快捷键技巧