# Message published but cant figure out the error.

**URL:** <https://community.solace.com/t/message-published-but-cant-figure-out-the-error/2004>\
**Category:** General Discussions\
**Tags:** python, json\
**Created:** [August 26, 2024, 1:33pm UTC](https://community.solace.com/t/message-published-but-cant-figure-out-the-error/2004 "2024-08-26T13:33:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amey](https://avatars.discourse-cdn.com/v4/letter/a/a8b319/32.png) [@Amey](https://community.solace.com/u/Amey)\
**Post date:** [August 26, 2024, 1:33pm UTC](https://community.solace.com/t/message-published-but-cant-figure-out-the-error/2004/1 "2024-08-26T13:33:00Z")

</div>

Hello I am new to Solace. I want to publish messages to solace.  
I have messages in JSON format which I convert in bytes and then publish it. At the receiver’s end we can see that the messgae is receieved but I get the following error.

**"Exception is class com.solacesystems.jms.message.SolMessage cannot be cast to class com.solacesystems.jms.message.SolBytesMessage (com.solacesystems.jms.message.SolMessage and com.solacesystems.jms.message.SolBytesMessage are in unnamed module of loader ‘app’)**

**ABC Number is null**

**Found a Text encoded message "**

I am using python script to do this. Please if someone could help and have face similar issues earlier. Let me know.

---

<div class="post-metadata">

**Author:** ![Tamimi](https://yyz1.discourse-cdn.com/solace/user_avatar/community.solace.com/tamimi/32/2190_2.png) [@Tamimi](https://community.solace.com/u/Tamimi)\
**Post date:** [August 28, 2024, 1:45pm UTC](https://community.solace.com/t/message-published-but-cant-figure-out-the-error/2004/2 "2024-08-28T13:45:04Z")

</div>

Hey @Amey - I was able to run the solace python samples just now with a json body and the receiver was able to `json.loads()` the body. Are you able to run the samples here

> **[GitHub - SolaceSamples/solace-samples-python: Getting Started Samples for the Solace Python API.](https://github.com/SolaceSamples/solace-samples-python)**
>
> Getting Started Samples for the Solace Python API.

---

<div class="post-metadata">

**Author:** ![Aaron](https://yyz1.discourse-cdn.com/solace/user_avatar/community.solace.com/aaron/32/843_2.png) [@Aaron](https://community.solace.com/u/Aaron)\
**Post date:** [August 28, 2024, 6:34pm UTC](https://community.solace.com/t/message-published-but-cant-figure-out-the-error/2004/3 "2024-08-28T18:34:58Z")

</div>

It sounds like you’re trying to consume your Python-published message using JMS? Trying to guess from your exception / error text above, are you trying to cast a received JMS message to a `BytesMessage` without checking if it is…? Looks like it could be a `TextMessage` .

Maybe your JMS consumer needs to do something like:

```javascript

if (msg instanceof TextMessage) {
    TextMessage txt = (TextMessage)msg;
    String payload = txt.getText();
    // more here
} else if (msg instanceof BytesMessage) {
    BytesMessage bytes = (BytesMessage)msg;
    // more here
} else // blah blah

```

Also, when you mention you want to “convert your JSON to bytes”, what does that mean? Like, serialize it to AVRO as a binary format payload? Or just send the JSON string as a binary message? Or …?
