Messaging exception: org.springframework.messaging.MessageDeliveryException: Dispatcher has no subscribers for channel 'org.springframework.web.context.WebApplicationContext:/.sftpChannel'.; nested exception is org.springframework.integration.MessageDispatchingException: Dispatcher has no subscribers
I am trying to send file from local to remote server.
My application context is below
<bean id="startupBean" class="com.SchedulerImpl" init-method="run"/>
<bean id="applicationContextProvider" class="com.ApplicationContextProvider"></bean>
<bean id="sftpSessionFactory" class="org.springframework.integration.file.remote.session.CachingSessionFactory">
<constructor-arg ref="defaultSftpSessionFactory" />
</bean>
<bean id="defaultSftpSessionFactory" class="org.springframework.integration.sftp.session.DefaultSftpSessionFactory">
<property name="host" value="${destination.host}"/>
<property name="privateKey" value="${destination.privateKey}"/>
<property name="privateKeyPassphrase" value="${destination.privateKeyPassphrase}"/>
<property name="port" value="${destination.port}"/>
<property name="user" value="${destination.user}"/>
<property name="sessionConfig" ref="props"/>
</bean>
<util:properties id="props">
<prop key="PreferredAuthentications">publickey</prop>
</util:properties>
<int:channel id="sftpChannel"/>
<int-sftp:outbound-channel-adapter id="sftpOutboundAdapter"
session-factory="sftpSessionFactory"
channel="sftpChannel"
auto-startup ="false"
charset="UTF-8"
remote-directory="/destinationFolder/"
remote-file-separator="/">
</int-sftp:outbound-channel-adapter>
<int:publish-subscribe-channel id="contextRefreshEvents"/>
<int:outbound-channel-adapter channel="contextRefreshEvents"
expression="sftpOutboundAdapter.start()" />
so I get same instance of applicationContext inside code of sftp class as:
ApplicationContext context = appContext.getApplicationContext();
MessageChannel sftpChannel = (MessageChannel)context.getBean("sftpChannel");
and @Autowired private ApplicationContextProvider appContext; inside same sftp class.
there's another class ApplicationContextProvider which implements ApplicationContextAware which helps me to get current ApplicaitonContext.
I dont understand why I get No subscriber found. I have put auto-startup=false. what would be correct way of getting current sftpChannel bean which gives me same instance of applicationContext.
If I do appContext = new classpathxmlapplicationcontext(applicationcontext.xml ) I get error in startupBean, so I dont want to do that.
Now I am implementing ApplicationContextAware, and I get Messaging exception.
could anyone please help me out?
I am using spring 3