There is an assumption that the incoming javax.jms.Message is a BytesMessage, and a direct cast is made. There should be an else/if block that uses instanceof to detect from the possible list of subclasses, then does the appropriate cast so the content can be retrieved safely.