In mule 3.8, when I use file connector to process text file , I am getting exception as below, please help.
Here is flow xml
file:connector name="File" autoDelete="true" streaming="true" validateConnections="true" doc:name="File"/>
flow name="DW-FixedWidth-Processing">
file:inbound-endpoint path="D:/mule/input" connector-ref="File" responseTimeout="10000" doc:name="File"/>
file:file-to-string-transformer doc:name="File to String"/>
dw:transform-message doc:name="Transform Message">
dw:input-payload />
dw:set-payload><![CDATA[%dw 1.0
%output application/csv header=false
---
((payload splitBy /\n/)[0..8]) map {
location:trim $[0..14],
sku:trim $[15..39],
dtc:trim $[40..42],
tt:trim $[43..44],
txnqty:trim $[45..54],
um:trim $[55..56],
rcd:trim $[57..59],
te:trim $[60..89],
ul:trim $[90..104],
date:trim $[105..114],
time:trim $[115..120]
} ]]>
dw:set-payload>
dw:transform-message>
logger message="#[message.payloadAs(java.lang.String)]" level="INFO" doc:name="Logger"/>
file:outbound-endpoint path="D:/mule/output" responseTimeout="10000" doc:name="File"/>
Exception
Root Exception stack trace:
java.lang.IllegalStateException: No schema set at com.mulesoft.weave.module.flatfile.FlatFileSettings.loadSchema(FlatFileSettings.scala:45) at com.mulesoft.weave.module.flatfile.FlatFileReader.ffParser(FlatFileReader.scala:42)
When you disable streaming in the file connector, you no longer need the
You can configure DataWeave to use a flat file schema, as already said in the other answer.
When you want to use it the way, you have to tell the correct mime type, in this case it is
You can do this on any message processor before the DataWeave, in this case the file:inbound-endpoint. Or you can do this in the DataWeave itself (unfortunately this is only visible when you switch Studio to XML).
For me everything worked with the following flow:
The result of the DataWeave is a List of HashMap.