java - Mule choice expression gives Stream Closed error -


i have below mule flow convert xml messages flat format , trnsfer ftp according type of input xml file (using choice). once put message gives below exceptions. can guys please identify problem.

<flow name="awoutboundflow">     <file:inbound-endpoint path="e:\muletemp\dbs\outbound\aw\in" responsetimeout="10000" doc:name="file"/>     <set-variable variablename="millis" value="#[system.currenttimemillis()]" doc:name="variable"/>     <logger message="#[flowvars['millis']]" level="info" doc:name="logger"/>     <choice doc:name="choice">         <when expression="#[xpath3('/cw:universalshipment/cw:shipment/cw:transportmode/cw:code') == 'air']">             <logger message="#[flowvars['millis']]: classified aw" level="info" doc:name="logger"/>             <mulexml:jaxb-xml-to-object-transformer returnclass="com.chasoft.schema.universalshipmentdata" encoding="utf-8" mimetype="text/xml" jaxbcontext-ref="jaxb_context" doc:name="xml jaxb object"/>             <transformer ref="awshipmentoutbound" doc:name="transformer reference"/>             <ftp:outbound-endpoint binary="true" host="localhost" port="21" path="/outbound/aw/out" user="dbs" password="502011" responsetimeout="60000" doc:name="ftp" outputpattern="aw_out_#[flowvars['millis']].dat" encoding="utf-8">                 <reconnect frequency="10000"/>             </ftp:outbound-endpoint>         </when>         <when expression="#[xpath3('/cw:universalshipment/cw:shipment/cw:transportmode/cw:code') == 'sea']">             <logger message="#[flowvars['millis']]: classified bl" level="info" doc:name="logger"/>             <mulexml:jaxb-xml-to-object-transformer returnclass="com.chasoft.schema.universalshipmentdata" encoding="utf-8" mimetype="text/xml" jaxbcontext-ref="jaxb_context" doc:name="xml jaxb object"/>             <transformer ref="blshipmentoutbound" doc:name="transformer reference"/>             <ftp:outbound-endpoint binary="true" host="localhost" port="21" path="/outbound/bl/out" user="dbs" password="502011" responsetimeout="60000" doc:name="ftp" outputpattern="bl_out_#[flowvars['millis']].dat"/>         </when>         <when expression="#[xpath3('/cw:universalevent/cw:event/cw:eventtime') != '']">             <logger message="#[flowvars['millis']]: classified toevent" level="info" doc:name="logger"/>             <mulexml:jaxb-xml-to-object-transformer jaxbcontext-ref="jaxb_context" doc:name="xml jaxb object" encoding="utf-8" mimetype="text/xml" returnclass="com.chasoft.schema.universaleventdata"/>             <transformer ref="eventoutbound" doc:name="transformer reference"/>             <ftp:outbound-endpoint binary="true" host="localhost" port="21" path="/outbound/event/out" user="dbs" password="502011" responsetimeout="60000" doc:name="ftp" outputpattern="event_out_#[flowvars['millis']].dat"/>         </when>         <otherwise>             <logger level="info" message="#[flowvars['millis']]: unknown classification" doc:name="logger"/>         </otherwise>     </choice> </flow> 

scratch of sample input file:

<universalshipment xmlns="http://www.cargowise.com/schemas/universal/2011/11" version="1.1">     <shipment>       .....         <transportmode>             <code>air</code>             <description>air freight</description>         </transportmode> 

exception:

error 2016-01-27 23:03:17,453 [[dbschenker].awoutboundflow.stage1.04] org.mule.exception.defaultmessagingexceptionstrategy: message : execution of expression "xpath3('/cw:universalshipment/cw:shipment/cw:transportmode/cw:code') == 'sea'" failed. (org.mule.api.expression.expressionruntimeexception). message payload of type: deferreddocumentimpl type : org.mule.api.messagingexception code : mule_error--2 javadoc : http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/messagingexception.html payload : [#document: null]

exception stack is: 1. stream closed (java.io.ioexception) java.io.fileinputstream:-2 (null) 2. java.io.ioexception: stream closed (org.mule.api.muleruntimeexception) org.mule.module.xml.el.xpath3function:151 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/muleruntimeexception.html) 3. [error: java.io.ioexception: stream closed] [near : {... xpath3('/cw:universalshipment/ ....}] ^ [line: 1, column: 1] (org.mule.mvel2.compileexception) org.mule.mvel2.optimizers.impl.refl.reflectiveaccessoroptimizer:438 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/mvel2/compileexception.html) 4. execution of expression "xpath3('/cw:universalshipment/cw:shipment/cw:transportmode/cw:code') == 'sea'" failed. (org.mule.api.expression.expressionruntimeexception) org.mule.el.mvel.mvelexpressionlanguage:232 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/expression/expressionruntimeexception.html) 5. execution of expression "xpath3('/cw:universalshipment/cw:shipment/cw:transportmode/cw:code') == 'sea'" failed. (org.mule.api.expression.expressionruntimeexception). message payload of type: deferreddocumentimpl (org.mule.api.messagingexception) org.mule.execution.exceptiontomessagingexceptionexecutioninterceptor:32 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/messagingexception.html)

here what's happening:

  • mule picks file , creates inputstream it,
  • it evaluates first xpath3 expression and, or this, consumes stream in order read file,
  • it tries evaluate second xpath3 expression , dies in fire because inputstream has been consumed, closed , can't read anymore.

solution: deserialize inputstream in byte[] before choice message processor <object-to-byte-array-transformer /> content can read again , again in downstream processors.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -