Announcement Announcement Module
Collapse
No announcement yet.
ftp:inbound-channel-adapter - No unique bean of type FileReadingMessageSource Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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

    Comment


    • #3
      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

      Comment


      • #4
        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>

        Comment


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

          Thanks,
          Tony

          Comment


          • #6
            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, 12:31 PM.

            Comment


            • #7
              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.

              Comment


              • #8
                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..

                Comment


                • #9
                  What do you mean by "not working"; I suggest you turn on debug logging to see polling activity.

                  Comment


                  • #10
                    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?

                    Comment


                    • #11
                      Your cron expression is bad; it means every 10 seconds during the 0th minute (15:00 and 16:00 only).

                      Code:
                      cron="*/10 * 15-16 * * MON-FRI"
                      works fine for me

                      Comment


                      • #12
                        Thanks. Its working now.

                        Comment


                        • #13
                          Cron Expression on file inbound adapter

                          Hi,
                          0 0/15 22-7 * * MON-FRI, Is there anything wrong with this cron expression?

                          In the poller, when I provide this cron expression it throws exception

                          Could not instantiate bean class [org.springframework.scheduling.support.CronTrigger]: Constructor threw exception; nested exception is java.lang.IndexOutOfBoundsException: fromIndex: 22 > toIndex: 8
                          at org.springframework.beans.BeanUtils.instantiateCla ss(BeanUtils.java:162)
                          at org.springframework.beans.factory.support.SimpleIn stantiationStrategy.instantiate(SimpleInstantiatio nStrategy.java:110)
                          at org.springframework.beans.factory.support.Construc torResolver.autowireConstructor(ConstructorResolve r.java:280)
                          ... 14 more
                          Caused by: java.lang.IndexOutOfBoundsException: fromIndex: 22 > toIndex: 8

                          When I provide the below expression
                          0/15 7-22 * * MON-FRI. It works.

                          Comment


                          • #14
                            22-7 should be 7-22

                            That should be obvious...
                            java.lang.IndexOutOfBoundsException: fromIndex: 22 > toIndex: 8

                            Comment


                            • #15
                              You are right. Sorry I got the point. Actually I forgot to mention one more point I want to schedule it from 23:00 hrs to morning 07:00 hrs in North American Eastern Time Zone? Is it possible to acheive it?

                              Comment

                              Working...
                              X