4 Replies Latest reply on Jun 9, 2005 10:29 AM by jetsnail

    Problem when publish MapMessage!

    jetsnail

      Hi,
      I write a sample Object named TestObj for MapMessage and publish a MapMessage by the following code:

      MapMessage msg = tsession_.createMapMessage();
       msg.setBoolean("Boolean", TestObj.BOOLEAN);
       msg.setByte("Byte", TestObj.BYTE);
       msg.setBytes("Bytes", TestObj.BYTEARRAY);
       msg.setChar("Char", TestObj.CHAR);
       msg.setDouble("Double", TestObj.DOUBLE);
       msg.setFloat("Float", TestObj.FLOAT);
       msg.setInt("Int", TestObj.INT);
       msg.setLong("Long", TestObj.LONG);
       msg.setObject("Object", TestObj.INTEGER);
       msg.setShort("Short", TestObj.SHORT);
       msg.setString("String", str);
       tpublisher_.publish(msg);

      Error came out as:
      Exception in thread "main" java.lang.NoSuchMethodError: org.jboss.util.Primitive
      s.valueOf(Z)Ljava/lang/Boolean;
      at org.jboss.mq.SpyMapMessage.setBoolean(SpyMapMessage.java:66)
      at SampleTopicPublisher.publishMapMessage(SampleTopicPublisher.java:179)

      I modifed the code by comment the following:
      msg.setBoolean("Boolean", TestObj.BOOLEAN);
       then the error gone and message was sent sucessfully.
      Since boolean type is important for me application, anyone can help me with this? Thanks very much!


        • 1. Re: Problem when publish MapMessage!
          starksm64

          Looks like you have out of date jboss-common.jar, or at least an out of date org.jboss.util.Primitives class in some jar visible to this test client.

          • 2. Re: Problem when publish MapMessage!
            jetsnail

            Hi Scott,
            I am using Jboss 4.0.2 for the test. I think it is the latest version. I also check the org.jboss.util.Primitives class I used in my client, It's new one. The modify date for the class is 2005-5-2. I am really confused. Could you lend me a hand? Thanks!

            • 3. Re: Problem when publish MapMessage!
              starksm64

              The following unit test works fine for me. You need to track down the source of the invalid org.jboss.util.Primitives class in your classpath.

               public void testMapMessage() throws Exception
               {
               log.info("+++ testMapMessage");
               MapMessage sent = session.createMapMessage();
               sent.setBoolean("Boolean", true);
               sent.setByte("Byte", (byte) 1);
               sent.setBytes("Bytes", "Bytes".getBytes());
               sent.setChar("Char", 'c');
               sent.setShort("Short", (short) 31415);
               sent.setInt("Int", 314159);
               sent.setLong("Long", 3141592653589793238L);
               sent.setDouble("Double", 3.1415926535897932384626433832795);
               sent.setFloat("Float", 3.141f);
               sent.setObject("Object", "31415926535897932384626433832795");
               sent.setString("String", "31415926535897932384626433832795");
              
               MapMessage recv = (MapMessage) sendRecMsg(sent);
               log.debug("recv: "+recv);
               assertTrue("Boolean == true", recv.getBoolean("Boolean") == true);
               assertTrue("Byte == 1", recv.getByte("Byte") == 1);
               assertTrue("Bytes == Bytes[]",
               Arrays.equals(recv.getBytes("Bytes"), "Bytes".getBytes()));
               assertTrue("Char == c", recv.getChar("Char") == 'c');
               assertTrue("Short == 314159", recv.getShort("Short") == 31415);
               assertTrue("Int == 314159", recv.getInt("Int") == 314159);
               assertTrue("Long == 3141592653589793238L",
               recv.getLong("Long") == 3141592653589793238L);
               assertTrue("Double == 3.1415926535897932384626433832795",
               recv.getDouble("Double") == 3.1415926535897932384626433832795);
               assertTrue("Float == true", recv.getFloat("Float") == 3.141f);
               assertTrue("Object == 31415926535897932384626433832795",
               recv.getObject("Object").equals("31415926535897932384626433832795"));
               assertTrue("String == 31415926535897932384626433832795",
               recv.getString("String").equals("31415926535897932384626433832795"));
               }
              



              • 4. Re: Problem when publish MapMessage!
                jetsnail

                Hi Scott,
                Thank you very much for your response. Finally it turned out that that was my mistake. Yes, you are right, old version of Primitives was used in my programm. the package was not added to CLASSPATH but defined in manifest of other jar file. So it was tricky to find.
                Thanks for your concern again!!!