Page 1 of 3 123 LastLast
Results 1 to 10 of 21

Thread: ftp:inbound-channel-adapter - No unique bean of type FileReadingMessageSource

  1. #1

    Default ftp:inbound-channel-adapter - No unique bean of type FileReadingMessageSource

    Hi guys,

    I started playing around with the ftp package today and found that the error below appears when I run my test program. But the weird thing is that the test completes fully, the file is fetched and placed onto a series of integration components and processed correctly.

    Any idea why this error appears in the console output? It's one of those red errors too, and we all know that they are never good.

    Code:
    14:37:14.927 INFO  [main][org.springframework.integration.endpoint.EventDrivenConsumer] started _org.springframework.integration.errorLogger
    14:37:14.931 INFO  [main][org.springframework.integration.endpoint.SourcePollingChannelAdapter] started ftpPuller
    Exception in thread "main" org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [org.springframework.integration.file.FileReadingMessageSource] is defined: expected single bean but found 0: 
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:271)
    	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1083)
    	at com.dnb.integration.SpringIntegrationUtils.displayDirectories(SpringIntegrationUtils.java:53)
    	at com.dnb.integration.Main.main(Main.java:61)
    14:37:16.897 INFO  [task-scheduler-1][org.springframework.integration.ftp.session.FtpSession] File has been successfully transfered from: //INTEGRATIONTEXT.txt
    14:37:17.062 INFO  [task-scheduler-1][org.springframework.integration.file.FileReadingMessageSource] Created message: [[Payload=C:\temp\IntegrationTest\PollingFolder\INTEGRATIONTEXT.TXT.a][Headers={timestamp=1350049037062, id=16995519-5efa-4bbe-80fd-2cf49897e98b}]]
    Here's my config file:

    Code:
    <int-ftp:inbound-channel-adapter id="ftpPuller"
    	session-factory="ftpClientFactory"
    	channel="filesIn"
    	charset="UTF-8"
    	auto-create-local-directory="true"
    	delete-remote-files="true"
    	filename-pattern="*.txt"
    	remote-directory="/"
    	remote-file-separator="/"
    	local-filename-generator-expression="#this.toUpperCase() + '.a'"
    	local-directory="C:\temp\IntegrationTest\PollingFolder">
    		<int:poller fixed-rate="5000"/>
    </int-ftp:inbound-channel-adapter>
    
    <int:channel id="filesIn" />
    Please ignore the name of the local dir, I had begun by dropping the file into a folder which was being polled and having a file inbound channel adapter, but using the ftp channel I think I can skip this part.

    Cheers,
    Tony

  2. #2

    Default

    Has anyone seen this message before? Where is FileReadingMessageSource used when specifying an FTP inbound channel? It's like I have two beans of the same type and it doesn't know which to inject or something, but I have checked my config and the channels all seem to link together correctly...

    Cheers,
    Tony

  3. #3

    Default

    UPDATE: Eventually I went back to using the directory poller and redirecting the channel to nullChannel. This seemed to remove the error and the flow now works fine.

    Thanks,
    Tony

  4. #4

    Default Exception File inbound adapter @2.2.1-RELEASE

    Why I am getting this exception?

    org.springframework.beans.factory.NoSuchBeanDefini tionException: No unique bean of type [org.springframework.integration.file.FileReadingMe ssageSource] is defined: expected single bean but found 2: org.springframework.integration.file.config.FileRe adingMessageSourceFactoryBean#0,org.springframewor k.integration.file.config.FileReadingMessageSource FactoryBean#1

    I am trying to use the below code to read file from two different sources and drop into same destination using file outbound adapter.

    <int-file:inbound-channel-adapter directory="file://${to.transfer}" filename-regex="${file.pattern}"
    queue-size="10" auto-create-directory="true" channel="localfile">
    <intoller id="poller" default="false"
    fixed-delay="${file.poller}"
    time-unit="SECONDS"
    max-messages-per-poll="10"
    error-channel="ftpErrorChannel"/>
    </int-file:inbound-channel-adapter>

    <int-file:inbound-channel-adapter directory="file://${to.transfer.other}" filename-regex="${file.pattern}"
    queue-size="10" auto-create-directory="true" channel="fileother">

    <intoller id="poller" default="false"
    fixed-delay="${file.poller}"
    time-unit="SECONDS"
    max-messages-per-poll="10"
    error-channel="ftpErrorChannel"/>
    </int-file:inbound-channel-adapter>

  5. #5

    Default

    Hi Saurav, did you try giving the pollers unique IDs? Or extract it separately and reference it if it's the same?

    Thanks,
    Tony

  6. #6
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,027

    Default

    Can you provide the full stack trace?

    I presume you are trying to do something like this

    Code:
    context.getBean(FileReadingMessageSource.class)
    or

    Code:
    @Autowired
    private FileReadingMessageSource messageSource;
    Can you explain why you need to get a reference to the MessageSource?

    You can't do that when there are more than one in the context. There is currently no mechanism to get a reference to these objects using "friendly" names, but you can use

    Code:
    context.getBean("org.springframework.integration.file.config.FileReadingMessageSourceFactoryBean#0",
    			 FileReadingMessageSource.class)
    or
    Code:
    @Autowired
    @Qualifier("org.springframework.integration.file.config.FileReadingMessageSourceFactoryBean#0")
    private FileReadingMessageSource messageSource;
    Where ...#0 is the first one parsed, ...#1, the next, etc.

    I see that the sample application uses this technique to find the directory property, This is not particularly good practice, but it's used there because the tmpdir directory is randomly generated on some platforms. You already know the directory so you shouldn't need this.
    Last edited by Gary Russell; Feb 12th, 2013 at 12:31 PM.
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  7. #7

    Default

    Hi Gary,
    You are right. It's my fault. Initially when I have started with application in STS. It was there. The codebase grew big now.I didn't notice that. It got fixed now. I removed it. My next task would be to clean up the codebase. Thanks Gary and Anthony.

  8. #8

    Default Cron Expression on file inbound adapter

    In the below configuration Am I missing anything?

    <int-file:inbound-channel-adapter id="fileIn" directory="file://${to.transfer}"
    filename-regex="${file.pattern}"
    queue-size="10" auto-create-directory="true" channel="localfile">

    <intoller id="poller" default="false"
    cron="*/10 0 15-16 * * MON-FRI"
    max-messages-per-poll="10"
    error-channel="ftpErrorChannel"/>

    Why it no working?
    Cron expression is not working..

  9. #9
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,027

    Default

    What do you mean by "not working"; I suggest you turn on debug logging to see polling activity.
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  10. #10

    Default

    Sorry .. I asked the same question into two places. After posting the question on the other one later I found it. Here this is the appropriate one. So I have posted it here.

    I turned on the DEBUG logging. As the cron expression indicates polling shall occur from 15-16 on every 10 seconds from MON-FRI. But still the polling was going on or I missed anything else. Kindly correct me if I am wrong. Do I need to configure anything else?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •