dcsimg
java.io.UTFDataFormatException: MapMessage trouble in SwiftMQ 3.2.0
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Adam_Skogman
Posted On:   Wednesday, October 9, 2002 03:00 AM

I send a simple map message through SwiftMQ 3.2.0: message = queueSession.createMapMessage(); message.setBoolean("boolean", true); message.setByte("byte", Byte.MAX_VALUE); message.setInt("int", Integer.MAX_VALUE); message.setLong("long", Long.MAX_VALUE); message.setChar("char", 'a'); message.setString("String", "åäö"); //swedish On receiving I do: message = (MapMessage) queueReceiver.receive(); boolean bo = message.getBoolean("boolean"); byte by = message.getByte("byte"); int in = message.getInt("int"); long l =    More>>

I send a simple map message through SwiftMQ 3.2.0:


			message = queueSession.createMapMessage();
			
message.setBoolean("boolean", true);
message.setByte("byte", Byte.MAX_VALUE);
message.setInt("int", Integer.MAX_VALUE);
message.setLong("long", Long.MAX_VALUE);
message.setChar("char", 'a');
message.setString("String", "åäö"); //swedish

On receiving I do:


			message = (MapMessage) queueReceiver.receive();
			

boolean bo = message.getBoolean("boolean");
byte by = message.getByte("byte");
int in = message.getInt("int");
long l = message.getLong("long");
char c = message.getChar("char");
String s = message.getString("String");

I then get:

			java.io.UTFDataFormatException
			
at com.swiftmq.tools.util.DataByteArrayInputStream.readUTF(DataByteArrayInputStream.java:191)
at com.swiftmq.jms.primitives._String.readContent(_String.java:41)
at com.swiftmq.jms.MessageProperties.readContent(MessageProperties.java:44)
at com.swiftmq.jms.MapMessageImpl.checkMap(MapMessageImpl.java:85)
at com.swiftmq.jms.MapMessageImpl.getBoolean(MapMessageImpl.java:96)
at jmstest.MapMessageConsumer.run(MapMessageConsumer.java:70)
at java.lang.Thread.run(Thread.java:479)

java.io.UTFDataFormatException
at com.swiftmq.tools.util.DataByteArrayInputStream.readUTF(DataByteArrayInputStream.java:191)
at com.swiftmq.jms.primitives._String.readContent(_String.java:41)
at com.swiftmq.jms.MessageProperties.readContent(MessageProperties.java:44)
at com.swiftmq.jms.MapMessageImpl.checkMap(MapMessageImpl.java:85)
at com.swiftmq.jms.MapMessageImpl.getByte(MapMessageImpl.java:113)
at jmstest.MapMessageConsumer.run(MapMessageConsumer.java:75)
at java.lang.Thread.run(Thread.java:479)



The exception thrown is: java.lang.NumberFormatException (from getByte).


So what may be wrong? Apparently everything gets encoded as strings when sending, and something goes wrong when trying to parse the strings in the receiver.

The producer and consumer are both running in the same JVM.

I've tried both Sun Jdk 1.4.1 and Sun JDK 1.3.1_04, both on win 2000. Same error.

   <<Less

Re: java.io.UTFDataFormatException: MapMessage trouble in SwiftMQ 3.2.0

Posted By:   Andreas_Mueller  
Posted On:   Wednesday, October 9, 2002 04:25 AM

You get it from getString, not from getByte. It has certainly to do with your Swedish characters. I don't know whether and how they map to UTF character. We had this problem with Thai character in the past as well. A work around is to transfer your Swedish characters as byte[].
About | Sitemap | Contact