0
votes

Can someone suggest the best / correct way of configuring the handlers in the getPipeline() method. When the client sends a message to the server it consists of custom objects, which contain the data required by the server. I have configured the handlers as shown below:

public ChannelPipeline getPipeline() throws Exception {
ChannelPipeline pipeline = pipeline();

SSLEngine engine = SecureSslContextFactory.getServerContext().createSSLEngine();
engine.setUseClientMode(false);

pipeline.addLast("ssl", new SslHandler(engine));

pipeline.addLast("decoder", new ObjectDecoder());
pipeline.addLast("encoder", new ObjectEncoder());

pipeline.addLast("pipelineExecutor", new ExecutionHandler(pipelineExecutor));

// and then business logic.
pipeline.addLast("handler", new SecureServerHandler());

return pipeline;
}

When I compile using Netty 3.2.7 Final, I get the following warning:

Warning(78,33): ObjectDecoder() in org.jboss.netty.handler.codec.serialization.ObjectDecoder has been deprecated

When the client send the message I get the following runtime error:

WARNING: Unexpected exception from downstream.
java.io.InvalidClassException: failed to read class descriptor
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1567)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
at org.jboss.netty.handler.codec.serialization.ObjectDecoder.decode(ObjectDecoder.java:129)
at org.jboss.netty.handler.codec.frame.FrameDecoder.callDecode(FrameDecoder.java:282)
at org.jboss.netty.handler.codec.frame.FrameDecoder.messageReceived(FrameDecoder.java:216)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:302)
at org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived(FrameDecoder.java:321)
at org.jboss.netty.handler.codec.frame.FrameDecoder.callDecode(FrameDecoder.java:299)
at org.jboss.netty.handler.codec.frame.FrameDecoder.messageReceived(FrameDecoder.java:216)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:274)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:261)
at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:351)
at org.jboss.netty.channel.socket.nio.NioWorker.processSelectedKeys(NioWorker.java:282)
at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:202)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)

1

1 Answers

0
votes

Your problem maybe the same as the following question: How to implement ObjectDecoder(ClassResolver) in Netty 3.2.7.

Try instancing the ObjectDecoder as new ObjectDecoder(ClassResolvers.weakCachingConcurrentResolver(null)) to get rid of warning.

If your class does not load, try specifying a class loader. See http://markmail.org/message/4ftws33dxehbzbwd.

Hope this helps.