Corrupt String or bytearray transport over RMI

Discussion in 'Java' started by Rolfje, Jul 25, 2005.

  1. Rolfje

    Rolfje Guest

    Hello,

    I have a strange problem when transporting a String and it's byteArray
    between 2 JVM's on the same machine. The JVMs are seperately started
    instances of IBM's 1.3.1 JVM which also comes with Websphere 4.5.

    On JVM1, I have something along the lines of:

    String jvm1String = "Some nice String";
    byte[] jvm1bytes = jvm1String.getBytes("ISO-8859-1");

    Now, I transport the string and the array through RMI toto JVM2. In
    JVM2 I do the following:

    jvm2bytes = jvm1String.getBytes("ISO-8859-1");

    for (int i = 0; i < jvm2bytes.length; i++) {
    if (jvm2bytes != jvm1bytes) return false;
    }

    This allways returns false. Manually checking the arrays shows that the
    two byte arrays only differ somewhere in the middle, and only for about
    2 bytes, regardless the content of the String. I have no idea what
    would cause java to behave differently between the two jvm's.

    My question is: Is this likely to be a bug in:
    a) the transportation of Strings over RMI
    b) the transportation of byte arrays over RMI
    c) the way String.getBytes("ISO-8859-1") is implemented
    d) the way I am using rmi or the getBytes() method

    Due to requirements, I can not change the JVM, so I need to find a way
    around this. I am using the bytearrays to verify data integrity.

    Thanks in advance,
    Rolf
    Rolfje, Jul 25, 2005
    #1
    1. Advertising

  2. Rolfje wrote:
    > This allways returns false. Manually checking the arrays shows that the
    > two byte arrays only differ somewhere in the middle, and only for about
    > 2 bytes, regardless the content of the String.


    And you don't want to tell us the exact difference? E.g. showing us the
    byte values which differ? Should we use our paranormal forces to guess
    them?


    > My question is: Is this likely to be a bug in:
    > a) the transportation of Strings over RMI
    > b) the transportation of byte arrays over RMI
    > c) the way String.getBytes("ISO-8859-1") is implemented
    > d) the way I am using rmi or the getBytes() method


    Get more facts. Use

    a) A debugger to inspect the original byte array and the received byte
    array to check the encoding.

    b) Compare the bytes to an ASCII / ISO Latin 1 code table to figure out
    which characters got encoded or decoded wrongly. I am surprised that you
    didn't do this already.

    c) Get a network sniffer like Ethereal and check what is actually going
    over the wire.

    /Thomas

    --
    The comp.lang.java.gui FAQ:
    ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
    http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/
    Thomas Weidenfeller, Jul 25, 2005
    #2
    1. Advertising

  3. Rolfje

    Rolfje Guest

    Re: Corrupt String or bytearray transport over RMI

    First of all, I humbly apologize for underestimating your paranormal
    forces :).

    I took your advise on inspecting the byte arrays. It seems I got so
    distracted by the character sets, toByteArray() and other distracting
    code, that I overlooked the fact that somewhere in the middle, the
    actual strings really did not match exactly.

    The cause of this all was a bug in a bussines class which mutilated
    itself when serializeing/ deserializing. Then, the toString() method
    was used to get the (rather large) byte array from.

    So, no magic here, just a plain overlooking of the obvious :)

    Thanks for putting me back on track, by sending me back to the debugger
    and inspect the data byte-by-byte.

    All the best,
    Rolf
    Rolfje, Jul 27, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Buu Nguyen

    RMI, JINI or RMI/IIOP

    Buu Nguyen, Aug 25, 2004, in forum: Java
    Replies:
    1
    Views:
    561
    Sudsy
    Aug 25, 2004
  2. Thomas
    Replies:
    2
    Views:
    361
    Thomas
    Sep 2, 2004
  3. JScoobyCed

    RMI Vs RMI over IIOP

    JScoobyCed, Jan 28, 2005, in forum: Java
    Replies:
    1
    Views:
    736
    Dag Sunde
    Jan 28, 2005
  4. Replies:
    7
    Views:
    6,702
    Alex Molochnikov
    Feb 23, 2005
  5. Jan Schulze
    Replies:
    1
    Views:
    569
    Esmond Pitt
    Mar 26, 2005
Loading...

Share This Page