ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » UTFDataFormatException on get

Post new topic  Reply to topic
 UTFDataFormatException on get « View previous topic :: View next topic » 
Author Message
r2504
PostPosted: Wed May 25, 2005 12:12 am    Post subject: UTFDataFormatException on get Reply with quote

Novice

Joined: 05 Mar 2004
Posts: 22

Hi,

I have a message in a queue which is tagged as MQSTR, CCSID 1208 (UTF8) encoding 273. The test message contains "Héllo world." and shows correctly when looking at it via Websphere Explorer.

Whenever I read this via a Java program, I however get a java.io.UTFDataFormatException on the message.readUTF() method. The get method itself worked fine and confirms the tagging as described above.

Looking at MQmessage.databuffer... the e-accent shows as -61 -87 (while in correct UTF-8 hex this is C3 A9 as seen in Websphere MQ Explorer).

What am I doing wrong... why can't I read UTF-8 messages from a queue.
Back to top
View user's profile Send private message
griffel
PostPosted: Wed May 25, 2005 12:42 am    Post subject: Reply with quote

Novice

Joined: 22 Mar 2005
Posts: 23

What do you mean by "read this via a Java program"?
Do you use JMS stuff? If so, beware of using TextMessage
which do UTF8-conversion on their own. Try using a
BytesMessage. Just an idea.
Back to top
View user's profile Send private message
r2504
PostPosted: Wed May 25, 2005 12:47 am    Post subject: Reply with quote

Novice

Joined: 05 Mar 2004
Posts: 22

No JMS... just plain MQ base Java programs.

Following is the piece of code...

Code:
MQMessage message = new MQMessage();
message.characterSet = 1208;
MQGetMessageOptions gmo = new MQGetMessageOptions();
gmo.options = MQC.MQGMO_WAIT;
gmo.waitInterval = MQC.MQWI_UNLIMITED;
queue.get(message, gmo);
Message = message.readUTF();


Since the message is tagged as MQSTR... it should do the conversion... but even then, Java is UTF-8, so I don't see the problem at all.
Back to top
View user's profile Send private message
r2504
PostPosted: Wed May 25, 2005 3:04 am    Post subject: Reply with quote

Novice

Joined: 05 Mar 2004
Posts: 22

I solved this now by forcing a conversion to 1252 (Windows) ...

Code:
MQMessage message = new MQMessage();
message.characterSet = 1252;
MQGetMessageOptions gmo = new MQGetMessageOptions();
gmo.options = gmo.options + MQC.MQGMO_WAIT + MQC.MQGMO_CONVERT;
gmo.waitInterval = MQC.MQWI_UNLIMITED;
queue.get(message, gmo);
Message = message.readString(message.getMessageLength());


... but still don't understand why this is necessary. It also no longer allows me to use readUTF() as it still crashes in that case.

Is Windows XP having a problem with UTF-8 ?
Back to top
View user's profile Send private message
bower5932
PostPosted: Wed May 25, 2005 6:08 am    Post subject: Reply with quote

Jedi Knight

Joined: 27 Aug 2001
Posts: 3023
Location: Dallas, TX, USA

I'd like to see the code that you use to actually put the message onto the queue and I'd also like to see the amqsbcg output of the message. The readUTF should be reading a string that is prefixed by a two byte length (which I think means the message isn't really in MQSTR format).
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
r2504
PostPosted: Wed May 25, 2005 7:05 am    Post subject: Reply with quote

Novice

Joined: 05 Mar 2004
Posts: 22

The code that puts the message on the queue is RPG code (runs on iSeries). Basically it sets MDCSI to 1208 and MDFMT to FMSTR and the buffer to the actual UTF-8 data (no prefix of length).
Back to top
View user's profile Send private message
bower5932
PostPosted: Wed May 25, 2005 8:39 am    Post subject: Reply with quote

Jedi Knight

Joined: 27 Aug 2001
Posts: 3023
Location: Dallas, TX, USA

r2504 wrote:
the buffer to the actual UTF-8 data (no prefix of length).


If you aren't specifying the length, then you should avoid using the readUTF method since it is expecting the data in the format of length|data. This is probably causing your DataFormatException.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
r2504
PostPosted: Wed May 25, 2005 9:53 am    Post subject: Reply with quote

Novice

Joined: 05 Mar 2004
Posts: 22

bower5932 wrote:
If you aren't specifying the length, then you should avoid using the readUTF method since it is expecting the data in the format of length|data. This is probably causing your DataFormatException.


I'll try to use the writeUTF() to see what it actually does generate since I don't have that method in RPG on iSeries. Anyway, this still leaves me with the question why it also doesn't work with readString()... unless I force a conversion to CCSID 1252.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » UTFDataFormatException on get
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.