2 Replies Latest reply on Jan 7, 2004 12:39 PM by jeanperrot

    String size limit in ObjectMessage

    jeanperrot Newbie


      There was a similar issue with TextMessage that was fixed a while back.

      I am finding that if I try to send an ObjectMessage after msg.setObjectProperty("property,longString) and longString past 64 kbytes, I get the following exception:

      org.jboss.mq.SpyJMSException: Cannot send a message to the JMS server

      with the following snipet:

      Client request resulted in a server exception:
      at java.io.ObjectInputStream$BlockDataInputStream.readUTFSpan(ObjectInputStream.java:2966)
      at java.io.ObjectInputStream$BlockDataInputStream.readUTFBody(ObjectInputStream.java:2891)
      at java.io.ObjectInputStream$BlockDataInputStream.readUTF(ObjectInputStream.java:2704)
      at java.io.ObjectInputStream.readUTF(ObjectInputStream.java:999)
      at org.jboss.mq.SpyMessage.readExternal(SpyMessage.java:774)
      at org.jboss.mq.SpyObjectMessage.readExternal(SpyObjectMessage.java:147)
      at org.jboss.mq.SpyMessage.readMessage(SpyMessage.java:636)
      at org.jboss.mq.il.oil.OILServerILService$Client.run(OILServerILService.java:248)
      at java.lang.Thread.run(Thread.java:536)

      I will be working around that but it would sure be more comfortable not to have too :)


        • 1. Re: String size limit in ObjectMessage
          Elias Ross Master

          I hear that JVM 1.3 may have problems deserializing strings > 64K in length. I think you can convert the property to bytes and back manually to work around this problem.

          E.g. setObjectProperty("hello", string.getBytes());

          • 2. Re: String size limit in ObjectMessage
            jeanperrot Newbie

            Thanks for the suggestion -- I should have specified:
            JVM 1.4.1, Jboss 3.2.1

            The issue has to do with SpyMessage.writeExternal() casting the message property back to String and then writing it out through writeUTF:

            if (value instanceof String) {
            out.writeUTF((String) value);

            by specs writeUTF will throw a UTFFormatException if the String is larger than 64kb -- whereas String serialization does work fine (w. 1.4.1 at least).

            setObjectProperty("hello", string.getBytes()) will not work as by specs setObjectProperty will not take a byte[] as argument.

            I guess I will be using setObject() instead of setObjectProperty() ...