Announcement Announcement Module
No announcement yet.
Migration from M5 to M6 --- FtpSource thows ClassCastException Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Migration from M5 to M6 --- FtpSource thows ClassCastException


    Here is my FtpSource configuration. Which was working perfectly fine with M5.

    <ftp-source id="rmsFtpServerRejectsSource"

    But, with M6... I get the following exception

    [8/25/08 13:50:30:245 PDT] 000000ef SystemOut O 2008-08-25 13:50:30,245 WARN [ lishingErrorHandler] - failure occurred in messaging task with message: null
    org.springframework.integration.message.MessagingE xception: Error while polling for messages.
    at org.springframework.integration.adapter.file.Abstr actDirectorySource.receive(AbstractDirectorySource .java:76)
    at org.springframework.integration.message.MessageExc hangeTemplate.doReceive(MessageExchangeTemplate.ja va:212)
    at org.springframework.integration.message.MessageExc hangeTemplate.doReceiveAndForward(MessageExchangeT
    at org.springframework.integration.message.MessageExc hangeTemplate.receiveAndForward(MessageExchangeTem
    at org.springframework.integration.dispatcher.Polling
    at org.springframework.integration.scheduling.spi.Pro viderTaskScheduler$
    at java.util.concurrent.Executors$ l(
    at java.util.concurrent.FutureTask$Sync.innerRunAndRe set(
    at java.util.concurrent.FutureTask.runAndReset(Future
    at java.util.concurrent.ScheduledThreadPoolExecutor$S cheduledFutureTask.access$101(ScheduledThreadPoolE
    at java.util.concurrent.ScheduledThreadPoolExecutor$S cheduledFutureTask.runPeriodic(ScheduledThreadPool
    at java.util.concurrent.ScheduledThreadPoolExecutor$S .java:181)
    at java.util.concurrent.ThreadPoolExecutor$ Task(
    at java.util.concurrent.ThreadPoolExecutor$ (
    Caused by:
    java.lang.ClassCastException: java.util.ArrayList incompatible with
    at org.springframework.integration.adapter.file.Abstr actFileMessageCreator.createMessage(AbstractFileMe
    at org.springframework.integration.adapter.file.Abstr actDirectorySource.buildNextMessage(AbstractDirect
    at org.springframework.integration.adapter.file.Abstr actDirectorySource.receive(AbstractDirectorySource .java:71)

  • #2
    Yes, in M6 some improvements have been made to make the FtpSource less wasteful on connections. One of the things I haven't hidden is the fact that the FtpSource returns a message containing a List<File> as a payload. If you want to use the same setup as before you'll have to add a splitter between the FtpSource and the rest of your system.

    If you post the exact code you're using to consume the messages we can probably find a way to make the error message a little more specific. If the MessageSource<T> is connected to MessageTarget<S> where !S.isAssignableFrom(T) we might be able to warn about that during the startup instead of letting the classcast exception happen at runtime.
    Last edited by iwein; Aug 26th, 2008, 12:46 AM.


    • #3
      Spring integration M6 might require another class like FtpFileMessageCreator

      Hi Iwein,
      Thanks for quick reply. I found the reason for ClassCastException.
      The default FtpSource is using org.springframework.integration.adapter.file.FileM essageCreator as a Message creator. But, this is not compatible with the the

      I have changed the FtpSource configuration as given below with custom MessageCreator.

      <bean id="ftpSource"
      class="org.springframework.integration.adapter.ftp .FtpSource">

      <constructor-arg ref="ftpFileMessageCreator"/>
      <constructor-arg ref="queuedFTPClient"/>
      <property name="localWorkingDirectory" value="${localTempDirectory}" />

      <bean id="ftpFileMessageCreator" class=""/>

      FtpFileMessageCreator .....

      public class FtpFileMessageCreator implements MessageCreator<List<File>, List<File>> {

      public Message<List<File>> createMessage(List<File> object) {

      return new GenericMessage<List<File>>(object);


      With this configuration FtpSource works fine and i am able to ftp the files to remote server.

      Prabhakara Gangi.


      • #4
        Cheers, you are spot on! see issue

        You can still use the namespace and provide a message-creator there. I'll look into using a parametrized DefaultMessageCreator for this. You will be very welcome to comment on the issue linked


        • #5
          I changed the defaults to work with DefaultMessageCreator<T>. That should do the trick.