This week's book giveaway is in the Android forum.
We're giving away four copies of Learning Java by Building Android Games and have Jean-Marcel Belmont on-line!
See this thread for details.
Win a copy of Learning Java by Building Android Games this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

JMSTextMessage vs JMSBytesMessage  RSS feed

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
We have an MDB in our application which expects a TextMessage but is receiving a BytesMessage as a result we get ClassCastException at runtime.
The message is being sent by an external application.
Error -
Non-application exception occurred while processing method "onMessage" on bean "BeanId(confirm#confirm-ejb.jar#ConfirmMDB, null)". Exception data: java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor36.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java(Compiled Code))
at java.lang.reflect.Method.invoke(Method.java(Compiled Code))
at com.ibm.ejs.jms.listener.ServerSessionDispatcher.dispatch(ServerSessionDispatcher.java:37)
at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:91)
at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:127)
at com.ibm.ejs.jms.listener.ServerSession.run(ServerSession.java:375)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Compiled Code))
Caused by: javax.ejb.EJBException: nested exception is: java.lang.ClassCastException: com.ibm.jms.JMSBytesMessage


The message received is as expected and correct as follows:
=====================================================================================================================
MQ Message Header

StrucId : 'MD ' Version : 2 Report : 0[MQRO_NONE] MsgType : 8[MQMT_DATAGRAM] Expiry : -1[Not Expiring] Feedback : 0[MQFB_NONE]
Encoding : 273 CodedCharSetId : 819 Format : 'MQSTR ' Priority : 0 Persistence : 1[Persistent]
MsgId : X'414D5120474C534C543032202020202049C6D60120314658'
CorrelId : X'000000000000000000000000000000000000000000000000'
BackoutCount : 0
ReplyToQ : ' ' ReplyToQMgr : 'GLSLT02 '
UserIdentifier : 'gp '
AccountingToken : X'0332393100000000000000000000000000000000000000000000000000000006'
ApplIdentityData : ' '
PutApplType : '6'[MQAT_UNIX] PutApplName : ' '
PutDate : '20090327' PutTime : '21112593'
ApplOriginData : ' '
GroupId : X'000000000000000000000000000000000000000000000000'
MsgSeqNumber : '1' Offset : '0' MsgFlags : '0' OriginalLength : '-1'

Message Data

<?xml version="1.0" encoding="ISO-8859-1"?>
<acknowledgement xmlns="...">
<XML Data>
</acknowledgement>

=====================================================================================================================

I need to know what field in header identifies it as a BytesMessage as against a TextMessage?
Or is there some setting on MQ side which might be setting some flag to interprete it as ByteMessage?

Regards,
Ashish
 
Sheriff
Posts: 23714
50
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And why do you need to know that?
 
Ashish Shinde
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:And why do you need to know that?



What were are expecting is that it should be a TextMessage but seems the format is BytesMessage (as per the error).
Hence an exception is thrown and message sits on the queue and is not processed.
 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
check this link, might be useful.

ByteMessage vs TextMsg
 
Ashish Shinde
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Anurag Blore wrote:check this link, might be useful.

ByteMessage vs TextMsg



Hi Anurag,
Thanks for the link, I did get that the message format is not correct.
I think I know what to change and it shoudl solve the issue. Thanks for all the help.
 
Anurag Blore
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ashish,

If you know the solution, please post here so If anyone else has same problem they can get the solution instead of spending time to solve the issue.

Thanks,
anurag
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in the onMessage(Message message) you can do a check like :
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!