首页 文章

Spring Boot应用程序获取入站SFTP适配器的错误

提问于
浏览
0

例外:

引起:java.lang.IllegalArgumentException:evaluationContext不能为null

Stacktrace

Error creating bean with name 'sftpMessageSource_DebitNotification_SE' defined in com.canaldigital.tsi.bank.xml.config.BankFtpListner: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: evaluationContext must not be null
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sftpMessageSource_DebitNotification_SE' defined in com.canaldigital.tsi.bank.xml.config.BankFtpListner: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: evaluationContext must not be null
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766)
at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:134)
at com.canaldigital.tsi.core.CoreRunner.run(CoreRunner.java:29)
at com.canaldigital.tsi.bank.xml.App.main(App.java:18)
Caused by: java.lang.IllegalArgumentException: evaluationContext must not be null
at org.springframework.util.Assert.notNull(Assert.java:115)
at org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizer.afterPropertiesSet(AbstractInboundFileSynchronizer.java:154)
at org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizingMessageSource.afterPropertiesSet(AbstractInboundFileSynchronizingMessageSource.java:151)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
... 16 more

代码

public SessionFactory<LsEntry> sftpSessionFactory_listener() {
    DefaultSftpSessionFactory factory = new DefaultSftpSessionFactory();

    System.out.println("sftp host is::" + env.getProperty("sftp.host"));
    factory.setPrivateKey(sftpKeyResourceAdapter());
    factory.setHost(env.getProperty("sftp.host"));
    factory.setUser(env.getProperty("sftp.username"));
    factory.setPort(Integer.valueOf(env.getProperty("sftp.serverPort")));
    logger.debug("SFTP Session:::"+factory.getSession().isOpen());
    return new CachingSessionFactory<LsEntry>(factory);
}

public SftpInboundFileSynchronizer sftpInboundFileSynchronizer_DebitNotification_SE() {
    SftpInboundFileSynchronizer debitFileSynchronizer = new SftpInboundFileSynchronizer(sftpSessionFactory_listener());
    logger.debug("sftpInboundFileSynchronizer_DebitNotification_SE Starts");
    debitFileSynchronizer.setDeleteRemoteFiles(true);
    try {
        debitFileSynchronizer.setRemoteDirectory(remot );
        CompositeFileListFilter<LsEntry> debitFilters = new CompositeFileListFilter<>();
        debitFilters.addFilter(new AcceptOnceFileListFilter());

        debitFilters.addFilter(new SftpSimplePatternFileListFilter(ibs2BankConfigDAO.getApplicationConfiguration().get(
                "SE_CAMT_054d_FILE_NAME_PATTERN")));

        debitFilters.addFilter(lastModifiedFileFilter());

        debitFileSynchronizer.setFilter(debitFilters);

    } catch (IBS2BankException e) {
        logger.error("Error creating sftpInboundFileSynchronizer_DebitNotification_SE::" + e.getMessage());
    } catch (Exception e) {
        logger.debug("Error is:::"+e.getMessage());
    }

    return debitFileSynchronizer;
}

@InboundChannelAdapter(value = "bankRequestListenerDebitNotification_SE", poller = @Poller(fixedDelay = "10000"))
@Bean
public MessageSource<File> sftpMessageSource_DebitNotification_SE() {
    logger.debug("sftpMessageSource_DebitNotification_SE Starts");
    SftpInboundFileSynchronizingMessageSource source = new SftpInboundFileSynchronizingMessageSource(
            sftpInboundFileSynchronizer_DebitNotification_SE());
    logger.debug("sftpMessageSource_DebitNotification_SE Starts1");
    source.setAutoCreateLocalDirectory(true);
    source.setLocalDirectory(new File("/ibs2bank/Temp_Download/Nordea/CAMT054D/SE"));
    logger.debug("sftpMessageSource_DebitNotification_SE Starts2");
    logger.debug("sftpMessageSource_DebitNotification_SE Starts3");
    source.setLocalFilter(new AcceptOnceFileListFilter<File>());
    logger.debug("sftpMessageSource_DebitNotification_SE Starts4");
    return source;
}

@Bean
public PollableChannel bankRequestListenerDebitNotification_SE() {
    return new QueueChannel();

}

1 回答

  • 0

    查看错误消息:

    在com.abc.tsi.bk.xml.config.BankFtpListner中定义名称为'sftpMessageSource_DebitNotification_SE'的bean创建错误:init方法的调用失败;嵌套异常是java.lang.IllegalArgumentException:evaluationContext不能为null

    显然,在尝试创建bean sftpMessageSource_DebitNotification_SE 时,对名为 evaluationContext 的参数进行空检查失败 .

    因此,你应该看看:

    public MessageSource<File> sftpMessageSource_DebitNotification_SE() {
    SftpInboundFileSynchronizingMessageSource source = new SftpInboundFileSynchronizingMessageSource(
            sftpInboundFileSynchronizer_DebitNotification_SE());
    source.setAutoCreateLocalDirectory(true);
    source.setLocalDirectory(new File("/ibs2bank/Temp_Download/Nordea/CAMT054D/SE"));
    source.setLocalFilter(new AcceptOnceFileListFilter<File>());
    return source;
    

    }

    source 可能有一个名为 evaluationContext 的属性,你没有设置也没有注入 .

相关问题