title: Netty - Send failed: UnsupportedOperationException: unsupported message type
body: <p>I am writing server-client app using Netty 4.1.9.</p>
  
  <p>Recently I successfully made communication using ByteBuf. 
  Then tried with String and succeed again.</p>
  
  <p>But with last step I wanted to send custom Object and there is my problem:</p>
  
  <pre><code>Send failed: java.lang.UnsupportedOperationException: unsupported message type: GIdPacket (expected: ByteBuf, FileRegion)
  </code></pre>
  
  <p>Some code parts</p>
  
  <p>Server:</p>
  
  <pre><code>ServerBootstrap b = new ServerBootstrap();
  b.group(bossGroup, workerGroup)
      .channel(NioServerSocketChannel.class)
      .childHandler(new ChannelInitializer&lt;SocketChannel&gt;() {
          @Override
          public void initChannel(SocketChannel ch) throws Exception {
               ch.pipeline().addLast(new ObjectDecoder(Integer.MAX_VALUE, ClassResolvers.cacheDisabled(null)));
               ch.pipeline().addLast(new ObjectEncoder());
               ch.pipeline().addLast(new ServerHandler());
               ch.pipeline().addLast(loggingHandler);
           }
       })
      .option(ChannelOption.SO_BACKLOG, 128)
      .childOption(ChannelOption.SO_KEEPALIVE, true)
      .option(ChannelOption.AUTO_READ, true);
  
  ChannelFuture f = b.bind(port).sync();
  </code></pre>
  
  <p>ServerHandler:</p>
  
  <pre><code>@Override
  public void channelActive(ChannelHandlerContext ctx) throws Exception
  {
      System.out.println("CHANNEL &gt;&gt; channelActive fired");
      clientData = new ClientData(Server.newId(), ctx.channel());
      Server.clients.put(clientData.id, clientData);
  
      GIdPacket packet = new GIdPacket(/*some init atr*/);
  
      ChannelFuture cf = ctx.writeAndFlush(packet);
      if (!cf.isSuccess()) {
          System.out.println("Send failed: " + cf.cause());
      }
  
      Log.out(packet.toString());
  }
  </code></pre>
  
  <p>So, I tried many different options. I spent much time on that and I didn't found solution. Any help appreciated.</p>