2 Replies Latest reply on Jul 10, 2012 8:50 AM by Balaji Ramalingam

    CommandAwareRpcDispatcher +  Problems unmarshalling remote command from byte buffer java.io.OptionalDataException

    Balaji Ramalingam Newbie

      Hi,

       

      I am trying to use Serializer concepts available in Infinispan. Also, instead of depending on java serialization, we are trying to convert the class definition to json string using jackson mapper and re-construct the object back on the other node.  But facing some issue during unmarshalling the object

       

      import org.infinispan.marshall.Externalizer;

      import org.infinispan.marshall.SerializeWith;

       

      @SerializeWith(ValueBean.ValueBeanExternalizer.class)

      public class ValueBean implements Serializable

      {

       

       

          private static final long serialVersionUID = -8660102578359275181L;

       

       

          private static final Log g_log = LogFactory.getLog(ValueBean.class);

       

       

          private Object valueObject;

       

       

          public ValueBean()

          {

       

       

          }

       

       

          public ValueBean(Object valueObject)

          {

              super();

              this.valueObject = valueObject;

          }

       

       

          public Object getValueObject()

          {

              return valueObject;

          }

       

       

          public void setValueObject(Object valueObject)

          {

              this.valueObject = valueObject;

          }

       

       

          @Override

          public String toString()

          {

              StringBuilder builder = new StringBuilder();

              builder.append("ValueBean [valueObject=").append(valueObject).append("]");

              return builder.toString();

          }

       

       

          public static class ValueBeanExternalizer implements Externalizer<ValueBean>

          {

              private static final long serialVersionUID = 3360406790942159766L;

       

       

              @Override

              public void writeObject(ObjectOutput output, ValueBean valueBean) throws IOException

              {

                  if (g_log.isInfoEnabled())

                  {

                      g_log.info("valueBean =" + valueBean);

                  }

       

       

                  String strObj = JSONMapper.toJSONString(valueBean);

       

       

                  if (g_log.isInfoEnabled())

                  {

                      g_log.info("Str obj = " + strObj);

                  }

                  output.writeObject(strObj);

              }

       

       

              @Override

              public ValueBean readObject(ObjectInput input) throws IOException, ClassNotFoundException

              {

                  if (g_log.isInfoEnabled())

                  {

                      g_log.info("input =" + input.readObject());

                  }

                 

                  Object cachedObject = JSONMapper.fromJSONString((String) input.readObject(), ValueBean.class);

       

       

                  ValueBean valueBean = cachedObject == null

                          ? null

                          : ((ValueBean) cachedObject);

                 

                  if (g_log.isInfoEnabled())

                  {

                      g_log.info("Value Bean Object = " + valueBean);

                  }

       

       

                  return valueBean;

              }

          }

      }

       

       

       

      INFO [OOB-20,localhost-10156] [15:11:14,040] (ValueBean.java:readObject:80) - input ={"appframework.appflow.context.ValueBean":{"valueObject":{"appframework.appflow.engine.StateBOIdentifier":{"m_featureName":null,"m_stateName":null,"m_stateId":"state_one"}}}}

       

      WARN [OOB-20,localhost-10156] [15:11:14,040] (CommandAwareRpcDispatcher.java:handle:207) - Problems unmarshalling remote command from byte buffer

      java.io.OptionalDataException

              at org.jboss.marshalling.river.BlockUnmarshaller.readObject(BlockUnmarshaller.java:151)

              at org.jboss.marshalling.river.BlockUnmarshaller.readObject(BlockUnmarshaller.java:139)

              at appframework.appflow.context.ValueBean$ValueBeanExternalizer.readObject(ValueBean.java:83)

              at appframework.appflow.context.ValueBean$ValueBeanExternalizer.readObject(ValueBean.java:54)

              at org.infinispan.marshall.jboss.JBossExternalizerAdapter.createExternal(JBossExternalizerAdapter.java:48)

              at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1277)

              at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:272)

              at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:209)

              at org.jboss.marshalling.AbstractObjectInput.readObject(AbstractObjectInput.java:37)

              at org.infinispan.marshall.exts.ReplicableCommandExternalizer.readParameters(ReplicableCommandExternalizer.java:119)

              at org.infinispan.marshall.exts.ReplicableCommandExternalizer.readObject(ReplicableCommandExternalizer.java:107)

              at org.infinispan.marshall.exts.ReplicableCommandExternalizer.readObject(ReplicableCommandExternalizer.java:58)

              at org.infinispan.marshall.jboss.ExternalizerTable$ExternalizerAdapter.readObject(ExternalizerTable.java:391)

              at org.infinispan.marshall.jboss.ExternalizerTable.readObject(ExternalizerTable.java:222)

              at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:351)

              at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:209)

              at org.jboss.marshalling.AbstractObjectInput.readObject(AbstractObjectInput.java:37)

              at org.infinispan.marshall.exts.ReplicableCommandExternalizer.readParameters(ReplicableCommandExternalizer.java:119)

              at org.infinispan.marshall.exts.CacheRpcCommandExternalizer.readObject(CacheRpcCommandExternalizer.java:163)

              at org.infinispan.marshall.exts.CacheRpcCommandExternalizer.readObject(CacheRpcCommandExternalizer.java:67)

              at org.infinispan.marshall.jboss.ExternalizerTable$ExternalizerAdapter.readObject(ExternalizerTable.java:391)

              at org.infinispan.marshall.jboss.ExternalizerTable.readObject(ExternalizerTable.java:222)

              at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:351)

              at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:209)

              at org.jboss.marshalling.AbstractObjectInput.readObject(AbstractObjectInput.java:37)

              at org.infinispan.marshall.jboss.AbstractJBossMarshaller.objectFromObjectStream(AbstractJBossMarshaller.java:154)

              at org.infinispan.marshall.VersionAwareMarshaller.objectFromByteBuffer(VersionAwareMarshaller.java:114)

              at org.infinispan.marshall.AbstractDelegatingMarshaller.objectFromByteBuffer(AbstractDelegatingMarshaller.java:85)

              at org.infinispan.remoting.transport.jgroups.MarshallerAdapter.objectFromBuffer(MarshallerAdapter.java:50)

              at org.infinispan.remoting.transport.jgroups.CommandAwareRpcDispatcher.handle(CommandAwareRpcDispatcher.java:200)

              at org.jgroups.blocks.RequestCorrelator.handleRequest(RequestCorrelator.java:447)

              at org.jgroups.blocks.RequestCorrelator.receiveMessage(RequestCorrelator.java:354)

              at org.jgroups.blocks.RequestCorrelator.receive(RequestCorrelator.java:230)

              at org.jgroups.blocks.MessageDispatcher$ProtocolAdapter.up(MessageDispatcher.java:542)

              at org.jgroups.JChannel.up(JChannel.java:715)

              at org.jgroups.stack.ProtocolStack.up(ProtocolStack.java:1015)

              at org.jgroups.protocols.pbcast.StreamingStateTransfer.up(StreamingStateTransfer.java:262)

       

      at org.jgroups.protocols.RSVP.up(RSVP.java:189)

       

              at org.jgroups.protocols.FRAG2.up(FRAG2.java:181)

              at org.jgroups.protocols.FlowControl.up(FlowControl.java:418)

              at org.jgroups.protocols.FlowControl.up(FlowControl.java:400)

              at org.jgroups.protocols.pbcast.GMS.up(GMS.java:884)

              at org.jgroups.protocols.pbcast.STABLE.up(STABLE.java:244)

              at org.jgroups.protocols.UNICAST2.handleDataReceived(UNICAST2.java:747)

              at org.jgroups.protocols.UNICAST2.up(UNICAST2.java:417)

              at org.jgroups.protocols.pbcast.NAKACK.up(NAKACK.java:601)

              at org.jgroups.protocols.VERIFY_SUSPECT.up(VERIFY_SUSPECT.java:140)

              at org.jgroups.protocols.FD.up(FD.java:273)

              at org.jgroups.protocols.FD_SOCK.up(FD_SOCK.java:282)

              at org.jgroups.protocols.MERGE3.up(MERGE3.java:290)

              at org.jgroups.protocols.Discovery.up(Discovery.java:355)

              at org.jgroups.protocols.TP.passMessageUp(TP.java:1194)

              at org.jgroups.protocols.TP$IncomingPacket.handleMyMessage(TP.java:1749)

              at org.jgroups.protocols.TP$IncomingPacket.run(TP.java:1731)

              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:662)

      Caused by: an exception which occurred:

              in object of type appframework.appflow.context.ValueBean

       

       

      Please let me know if I am missing something.

       

       

      Thanks

      Balaji