我自己写了个mima客户端程序连接服务器,但是报如下异常:
java.lang.IllegalStateException: handler is not set.
at org.apache.mina.core.service.AbstractIoAcceptor.bind(AbstractIoAcceptor.java:276)
at org.apache.mina.core.service.AbstractIoAcceptor.bind(AbstractIoAcceptor.java:221)
at com.game.server.test.action.Client.start(Client.java:111)
at com.game.server.test.action.TestMailLookAction.setUp(TestMailLookAction.java:12)
at junit.framework.TestCase.runBare(TestCase.java:125)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)我已经设置handler了,不知道为什么还会抛这个异常,是不是哪里写的有问题?
java.lang.IllegalStateException: handler is not set.
at org.apache.mina.core.service.AbstractIoAcceptor.bind(AbstractIoAcceptor.java:276)
at org.apache.mina.core.service.AbstractIoAcceptor.bind(AbstractIoAcceptor.java:221)
at com.game.server.test.action.Client.start(Client.java:111)
at com.game.server.test.action.TestMailLookAction.setUp(TestMailLookAction.java:12)
at junit.framework.TestCase.runBare(TestCase.java:125)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)我已经设置handler了,不知道为什么还会抛这个异常,是不是哪里写的有问题?
贴点代码
connector.getFilterChain().addLast("logger", new LoggingFilter());
connector.getFilterChain().addLast(
"Objectcodec",
new ProtocolCodecFilter((ProtocolCodecFactory) new ObjectSerializationCodecFactory()));
connector.setConnectTimeoutMillis(3000);
connector.setHandler(new ClientHandler());
另外, Nina自带了几个小例子,仔细看下,应该就都懂了。