IBM Support

Message-driven bean fails to process message and receives "java.lang.ClassCastException: com.ibm.jms.JMSBytesMessage"

Troubleshooting


Problem

A message-driven bean (MDB) running in WebSphere Application Server V5 or V6 may fail to process an incoming message and receive the following exception: java.lang.ClassCastException: com.ibm.jms.JMSBytesMessage

Cause

The problem occurs when a JMS message header is missing from a message. This can happen when the JMS destination that is used by the application that sends the message to the queue does not have the Target Client property set correctly. Because the message header is missing, WebSphere Application Server cannot determine the format of the message and delivers it to the MDB as a JMSBytesMessage. The MDB is not expecting this type of message, and the ClassCastException occurs when it tries to process the message.

Resolving The Problem

To correct the problem, the Target Client property of the JMS destination that is used to send the message should be changed. If the sender application is running in WebSphere Application Server, you can edit the JMS destination in the Admin Console. Expand Resources, select WebSphere MQ JMS Provider, select WebSphere MQ Queue Destinations, and then select your JMS destination. Change the value of the Target Client property to JMS.

If the sender application is running outside of WebSphere Application Server, you can either use the JMSAdmin tool to set the targetClient on your JMS destination to 0 (equivalent to the "JMS" setting in the WebSphere Application Server Admin Console), or call setTargetClient(0) on the JMS destination object in your application before sending the message.

[{"Product":{"code":"SSEQTP","label":"WebSphere Application Server"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Java Message Service (JMS)","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"6.0;5.1","Edition":"Base;Enterprise;Express;Network Deployment;WebSphere Business Integrations Server Foundation","Line of Business":{"code":"LOB45","label":"Automation"}},{"Product":{"code":"SSNVBF","label":"Runtimes for Java Technology"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"Java SDK","Platform":[{"code":"","label":""}],"Version":"","Edition":"","Line of Business":{"code":"LOB36","label":"IBM Automation"}}]

Document Information

Modified date:
15 June 2018

UID

swg21220378