Kendre Paresh Kendre Paresh - 1 year ago 165
reST (reStructuredText) Question

Mule - java.lang.String cannot be cast to java.util.Map

I want to write a mule application which will read the database for unprocessed records, club them in JSON payload format and then hit a REST webservice.
I am able to read the records from the database and able to convert the database records in JSON. However, whenever I run the application I am getting following exception

java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map

Here is my Mule configuration XML

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:db="" xmlns:json="" xmlns:http="" xmlns="" xmlns:doc=""
<db:mysql-config name="MySQL_Configuration" host="localhost" port="3306" user="root" database="my_database_name" doc:name="MySQL Configuration"/>
<http:request-config name="HTTP_Request_Configuration" protocol="HTTPS" host="" port="8000" basePath="API" doc:name="HTTP Request Configuration"/>
<flow name="cwg_clientFlow">
<poll doc:name="Poll">
<db:select config-ref="MySQL_Configuration" doc:name="Database">
<db:parameterized-query><![CDATA[SELECT * FROM cwg_ws_data WHERE SyncFlag = 0]]></db:parameterized-query>
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
<json:object-to-json-transformer doc:name="Object to JSON" />
<logger message="JSON Payload is #[payload]" level="INFO" doc:name="Logger"/>
<http:request config-ref="HTTP_Request_Configuration" path="/cwg" method="POST" doc:name="HTTP">
<http:query-params expression="#[payload]"/>
<http:header headerName="access_token" value="MQTgpMUmyQLt134maB6vPp6oWFgMtGsqzIlpCN74"/>
<logger message="webservice response #[payload]" level="INFO" doc:name="Logger"/>

I am unable to understand where it is going wrong

Please help me, I am trying this since last 2 days.

Thanks in advance

-Paresh (

Answer Source

Try removing this line.

<http:query-params expression="#[payload]"/>

It should work. As your payload is Json String and you are trying to map it to Query params which expects Map. Also for POST your payload will converted to body.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download