0

i have used sftp:inbound-streaming-channel-adapter with zookeeper.but it is giving me exception : java.lang.ClassCastException: com.jcraft.jsch.ChannelSftp$LsEntry cannot be cast to java.io.File. I am using the following code

<int-sftp:inbound-streaming-channel-adapter
    id="sftpAdapter" channel="receiveChannel"
    session-factory="cachingSessionFactory" 
    remote-file-separator="/" remote-directory-expression="'${ftpServerLoc}'" filter="compositeFilter"
    auto-startup="true">
    <int:poller fixed-rate="${pollarInterval}"
        max-messages-per-poll="1" />
</int-sftp:inbound-streaming-channel-adapter>

  <beans:bean id="compositeFilter"
    class="org.springframework.integration.file.filters.CompositeFileListFilter">
    <beans:constructor-arg>
        <beans:list>
             <beans:bean
                class="org.springframework.integration.file.filters.RegexPatternFileListFilter">
                 <beans:constructor-arg value="^.*\.(dat|DAT)$" />

            </beans:bean>
            <beans:bean
                class="org.springframework.integration.sftp.filters.SftpPersistentAcceptOnceFileListFilter">
                <beans:constructor-arg name="store"
                    ref="metadataStore" />
                <beans:constructor-arg value="" />
            </beans:bean>
        </beans:list>
    </beans:constructor-arg>
</beans:bean>

1 Answers1

1

The org.springframework.integration.file.filters.RegexPatternFileListFilter should be org.springframework.integration.sftp.filters.SftpRegexPatternFileListFilter.

The one you have applies to java.io.File; the sftp version applies to LsEntry (Jsch's representation of the remote file).

Gary Russell
  • 166,535
  • 14
  • 146
  • 179
  • but now i am getting java.lang.IllegalArgumentException: Invalid path string "/metaDataStore/.." caused by relative paths not allowed @27 exception. – chetan agrawal Nov 08 '17 at 13:35
  • i am getting org.springframework.integration.zookeeper.metadata.ZookeeperMetadataStoreException: Error while trying to set '..' as well – chetan agrawal Nov 08 '17 at 13:37
  • That's a completely different, unrelated, problem; I suggest you ask a new question and show the complete stack trace. – Gary Russell Nov 08 '17 at 13:57