1

I have an application based in the Spring Web model-view-controller (Spring MVC 3.2.8 ) and I want to use the integration with FTP using the default implementation of FTP SessionFactory.

I have this class:

@Configuration
public class FtpConfiguration {

    @Autowired
    private SessionFactory myFtpSessionFactory;

    @Bean
    @Scope(value="step")
    public FtpGetRemoteFilesTasklet myFtpGetRemoteFilesTasklet()
    {
        FtpGetRemoteFilesTasklet  ftpTasklet = new FtpGetRemoteFilesTasklet();
        ftpTasklet.setRetryIfNotFound(true);
        ftpTasklet.setDownloadFileAttempts(3);
        ftpTasklet.setRetryIntervalMilliseconds(10000);
        ftpTasklet.setFileNamePattern("README");
        //ftpTasklet.setFileNamePattern("TestFile");
        ftpTasklet.setRemoteDirectory("/");
        ftpTasklet.setLocalDirectory(new File(System.getProperty("java.io.tmpdir")));
        ftpTasklet.setSessionFactory(myFtpSessionFactory);

        return ftpTasklet;
    }

    @Bean   
    public SessionFactory myFtpSessionFactory()
    {
        DefaultFtpSessionFactory ftpSessionFactory = new DefaultFtpSessionFactory();
        ftpSessionFactory.setHost("la.mare.superiora");
        ftpSessionFactory.setClientMode(0);
        ftpSessionFactory.setFileType(0);
        ftpSessionFactory.setPort(1029);
        ftpSessionFactory.setUsername("carbonell");
        ftpSessionFactory.setPassword("nicinc");

        return ftpSessionFactory;
    }

and this service:

@Service("jobone")
public class MyJobOne {

    private static final Logger LOGGER = Logger.getLogger   (MyJobOne.class);

    private File localDirectory;

    private AbstractInboundFileSynchronizer<?> ftpInboundFileSynchronizer;

    @Autowired
    private SessionFactory myFtpSessionFactory;

    ...
}

But when I run this service I got this error:

weblogic.application.ModuleException: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.integration.file.remote.session.SessionFactory] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}:org.springframework.beans.factory.NoSuchBeanDefinitionException:No qualifying bean of type [org.springframework.integration.file.remote.session.SessionFactory] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
La Carbonell
  • 1,976
  • 5
  • 22
  • 52

0 Answers0