2 Replies Latest reply on Oct 22, 2001 3:14 PM by Jesus del Valle

    readBytes throws NullPointerException for BytesMessages

    Jesus del Valle Newbie

      Hi. I am using JBoss 2.4.1 in Windows 2000. My java program sends and receives messages to/from the JBoss queue. Text, Map, Streams, Objects: No problem. But I keep getting a NullPointerException when trying to read the body of a BytesMessages using readBytes (b) or readBytes (b, b.length), calling reset () on bytesMessage before, etc. Below is the interesting piece of code:

      byte[] b = new byte[1024];
      BytesMessage bytesMessage = (BytesMessage) message;
      try {
      int j = 1024;
      b = new byte[j];
      int k = 0;
      while ((k = bytesMessage.readBytes (b)) != -1) {
      outputStream.write (b, 0, k);
      } catch (Exception e) {}

      Any solution would be highly appreciated. Thanks.