Hi Martin,
we developed File Listener based on Spring Annotations which are equivalent to the above approach you mentioned,but Spring is not able to auto create MessageChannel Bean with name "inboundchannel" and an exception is being thrown. will you be able to help here please ?
Code Snippet :
public static FileReadingMessageSource getFileReadingMessageSource() {
try {
if (fileReadingMessageSource == null) {
fileReadingMessageSource = new FileReadingMessageSource();
fileReadingMessageSource.setDirectory(new File(folderPath));
SimplePatternFileListFilter simplePatternFileListFilter = new SimplePatternFileListFilter(
filePattern);
IgnoreHiddenFileListFilter ignoreHiddenFileListFilter = new IgnoreHiddenFileListFilter();
List<FileListFilter<File>> fileListFilter = new ArrayList<FileListFilter<File>>();
fileListFilter.add(simplePatternFileListFilter);
fileListFilter.add(ignoreHiddenFileListFilter);
compositeFileListFilter = new CompositeFileListFilter<File>(
fileListFilter);
CustomScanner cs = new CustomScanner();
cs.setFilter(compositeFileListFilter);
fileReadingMessageSource.setScanner(cs);
}
} catch (Exception e) {
logger.debug("Exception while creating FileReadingMessageSource");
}
return fileReadingMessageSource;
}
@InboundChannelAdapter(value = "inboundchannel", poller = @Poller(fixedDelay = "5000", maxMessagesPerPoll = "1"))
public MessageSource<File> processFiles() {
fileReadingMessageSource = getFileReadingMessageSource();
logger.info("In processFiles() after getting FileReadingMessageSource from static method "
+ fileReadingMessageSource);
return fileReadingMessageSource;
}
@ServiceActivator(inputChannel = "inboundchannel")
public void process(Message<File> payload) {
logger.info("In process() … payload is" + payload.getClass());
processFile(payload);
}
Exception details :
Dec 21, 2015 3:22:11 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class com.activiti.servlet.WebConfigurer
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cSVFileProcessor' defined in URL [jar:file:/xjp/appserver_1/tomcat/apache-tomcat-7.0.42/webapps/activiti-app/WEB-INF/lib/nexen-workflow-ext-0.0.3.jar!/com/activiti/extension/bean/CSVFileProcessor.class]: Initialization of bean failed; nested exception is org.springframework.messaging.core.DestinationResolutionException: failed to look up MessageChannel with name 'inboundchannel' in the BeanFactory.; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'inboundchannel' is defined
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:547)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
at com.activiti.servlet.WebConfigurer.contextInitialized(WebConfigurer.java:67)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
at com.activiti.servlet.WebConfigurer.contextInitialized(WebConfigurer.java:67)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:656)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1635)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
Caused by: org.springframework.messaging.core.DestinationResolutionException: failed to look up MessageChannel with name 'inboundchannel' in the BeanFactory.; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'inboundchannel' is defined
at org.springframework.integration.support.channel.BeanFactoryChannelResolver.resolveDestination(BeanFactoryChannelResolver.java:112)
at org.springframework.integration.support.channel.BeanFactoryChannelResolver.resolveDestination(BeanFactoryChannelResolver.java:45)
at org.springframework.integration.config.annotation.InboundChannelAdapterAnnotationPostProcessor.postProcess(InboundChannelAdapterAnnotationPostProcessor.java:64)
at org.springframework.integration.config.annotation.MessagingAnnotationPostProcessor$1.doWith(MessagingAnnotationPostProcessor.java:177)
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:494)
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:501)
at org.springframework.integration.config.annotation.MessagingAnnotationPostProcessor.postProcessAfterInitialization(MessagingAnnotationPostProcessor.java:145)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:422)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1579)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
… 23 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'inboundchannel' is defined
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:687)
at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1168)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:281)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.integration.support.channel.BeanFactoryChannelResolver.resolveDestination(BeanFactoryChannelResolver.java:88)
… 32 more
Dec 21, 2015 3:22:11 PM org.apache.catalina.core.StandardContext listenerStop
SEVERE: Exception sending context destroyed event to listener instance of class com.activiti.servlet.WebConfigurer
java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?
at org.springframework.web.context.support.WebApplicationContextUtils.getRequiredWebApplicationContext(WebApplicationContextUtils.java:83)
at com.activiti.servlet.WebConfigurer.contextDestroyed(WebConfigurer.java:230)
at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4980)
at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5626)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:656)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1635)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)