Reputation: 214
I'm starting with Mule, and I've tried to execute some examples from their page, although almost always I'm getting the same error: "Message payload is of type: BufferInputStream", so I don't know if something is wrong with my flow. This is my XML
<mule xmlns:json="http://www.mulesoft.org/schema/mule/json"
xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:db="http://www.mulesoft.org/schema/mule/db" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" version="CE-3.6.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd">
<db:template-query name="insert_into_current" doc:name="Template Query">
<db:parameterized-query><![CDATA[INSERT INTO current("name", "date", "bookvalue") VALUES(:name,:date,:bookvalue);]]></db:parameterized-query>
<db:in-param name="name" defaultValue="#[xpath('//Name').text]"/>
<db:in-param name="date" type="DATE" defaultValue="#[xpath('//LastTradeDate').text]"/>
<db:in-param name="bookvalue" defaultValue="#[xpath('//BookValue').text])"/>
</db:template-query>
<http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8081" doc:name="HTTP Listener Configuration"/>
<http:request-config name="HTTP_Request_Configuration" host="query.yahooapis.com" basePath="v1/public/yql" doc:name="HTTP Request Configuration" port="80"/>
<db:mysql-config name="MySQL_Configuration" host="xxxxxx" port="3306" user="" password="xxxx" database="xxxx" doc:name="MySQL Configuration"/>
<flow name="financeapiFlow1" >
<http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
<http:request config-ref="HTTP_Request_Configuration" path="/" method="GET" followRedirects="true" doc:name="HTTP">
<http:request-builder>
<http:query-param paramName="q" value="#[message.inboundProperties.'http.query.params'.q]"/>
<http:query-param paramName="env" value="#[message.inboundProperties.'http.query.params'.env]"/>
<http:query-param paramName="format" value="#[message.inboundProperties.'http.query.params'.format]"/>
</http:request-builder>
</http:request>
<logger message=""### VALUES "+#[message.inboundProperties.'http.query.params'.q]+" - "+#[message.inboundProperties.'http.query.params'.env]+" - "+#[message.inboundProperties.'http.query.params'.format]" level="INFO" doc:name="Logger"/>
<json:json-to-object-transformer returnClass="java.util.Map" doc:name="JSON to Object"/>
<db:insert config-ref="MySQL_Configuration" doc:name="Database">
<db:dynamic-query><![CDATA[INSERT INTO MULE("symbol", "lastTradeDate", "bookvalue") VALUES('#[message.payload.query.results.quote.symbol]','#[message.payload.query.results.quote.LastTradeDate]','#[message.payload.query.results.quote.BookValue]');]]></db:dynamic-query>
</db:insert>
</flow>
This is my stack trace:
Exception stack is:
1. null (java.lang.NullPointerException)
org.mule.mvel2.optimizers.impl.refl.nodes.MapAccessor:42 (null)
2. cannot invoke getter: getInboundProperties (see trace) (java.lang.RuntimeException)
org.mule.mvel2.optimizers.impl.refl.nodes.GetterAccessor:70 (null)
3. Execution of the expression "message.inboundProperties.'http.query.params'.q" failed. (org.mule.api.expression.ExpressionRuntimeException)
org.mule.el.mvel.MVELExpressionLanguage:202 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/expression/ExpressionRuntimeException.html)
4. Execution of the expression "message.inboundProperties.'http.query.params'.q" failed. (org.mule.api.expression.ExpressionRuntimeException). Message payload is of type: BufferInputStream (org.mule.api.MessagingException)
org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor:32 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.lang.NullPointerException
at org.mule.mvel2.optimizers.impl.refl.nodes.MapAccessor.getValue(MapAccessor.java:42)
at org.mule.mvel2.optimizers.impl.refl.nodes.MapAccessor.getValue(MapAccessor.java:39)
at org.mule.mvel2.optimizers.impl.refl.nodes.GetterAccessor.getValue(GetterAccessor.java:40)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
Thanks!
Upvotes: 1
Views: 3399
Reputation: 2835
The problem is that once you get to the request
, the inboundProperties from the listener
are lost so the expression on the following logger
fails. I recommend saving those properties to variables or moving up the logger
if what you want is just to have visibility on what the HTTP request is going to look like.
Upvotes: 1