Skip to main content

Hi, I am trying with a task to read an XML file from a location and split by specific node and write each XML node into a separate file using batch job. I am using splitter in batch job input and in batch step, I am using the file connector to write the file. However, I am getting error as `ERROR 2018-08-10 15:38:01,801 [[apdev-handlexml-batch].FileReadingFlow.stage1.02] org.mule.exception.CatchMessagingExceptionStrategy:

********************************************************************************

Message : Object "java.lang.String" not of correct type. It must be of type "{interface java.lang.Iterable,interface java.util.Iterator,interface org.mule.routing.MessageSequence,interface java.util.Collection}" (java.lang.IllegalArgumentException)` .

 

Please help how to get avoid this error. Here is my code...`

 

<file:connector name="File" writeToDirectory="${file.outpath}" autoDelete="true" outputAppend="true" streaming="true" validateConnections="true" doc:name="File"/>

<flow name="FileReadingFlow">

<file:inbound-endpoint responseTimeout="10000" doc:name="File" path="${file.path}">

</file:inbound-endpoint>

<batch:execute name="FileWritingBatchFlow" doc:name="FileWritingBatchFlow Execute"/>

<logger message="#&nbsp;[payload]" level="INFO" doc:name="Logger"/>

<exception-strategy ref="globalChoice_Exception_Strategy" doc:name="Reference Exception Strategy"/>

</flow>

<batch:job name="FileWritingBatchFlow">

<batch:input>

<splitter expression="#&nbsp;[xpath3('//food')]" doc:name="Splitter"/>

</batch:input>

<batch:process-records>

<batch:step name="Batch_Step">

<foreach collection="#&nbsp;[payload]" doc:name="For Each">

<file:outbound-endpoint path="${file.outpath}" outputPattern="#&nbsp;[org.apache.commons.io.FilenameUtils.removeExtension(flowVars.originalFilename)+'out'+server.dateTime.format('ddMMyyyyHHmmssSSS')+'.txt']" connector-ref="File" responseTimeout="10000" doc:name="File"/>

<logger message="#&nbsp;[message.outboundProperties.filename]" level="INFO" doc:name="Logger"/>

</foreach>

</batch:step>

</batch:process-records>

</batch:job>

 

`

2 answers
  1. Aug 13, 2018, 11:06 AM

    Hi, You need to convert the payload to a COLLECTION TYPE OBJECT before the batch reference call. So adding Transform Message(%output application/java) before the Batch Reference can do that. Also note that the Splitter in the Batch Input Phase is not executed if your calling the Batch Module via reference call.

     

    Hi, You need to convert the payload to a COLLECTION TYPE OBJECT before the batch reference call. So adding Transform Message(%output application/java) before the Batch Reference can do that.

     

0/9000