0

Exception:

Caused by: java.lang.IllegalArgumentException: evaluationContext must not be 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

Code

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();

}
David S.
  • 10,578
  • 12
  • 62
  • 104

1 Answers1

0

Look at the error message :

Error creating bean with name 'sftpMessageSource_DebitNotification_SE' defined in com.abc.tsi.bk.xml.config.BankFtpListner: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: evaluationContext must not be null

Clearly, when trying to create the bean sftpMessageSource_DebitNotification_SE, a null check of a parameter called evaluationContext failed.

Thus, you should look at :

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 probably has an attribute called evaluationContext that you did not set nor inject.

Jeremy Grand
  • 2,300
  • 12
  • 18
  • I know something is required and is set as null but evaluationContext is not my attribute it is something that belongs to spring. – Muhammad Amir Haif May 12 '17 at 14:27
  • @MuhammadAmirHaif you must look at the stacktrace to see which method threw the IllegalArgumentException and search what is this evaluationContext and how it could be set. You didn't give enough info in your question. – Jeremy Grand May 12 '17 at 14:36