Uploaded image for project: 'Spring Integration'
  1. Spring Integration
  2. INT-2275

Add support for any 'outbound-channel-adapter' as end-MessageHandler of the <chain>

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: 2.0.5
    • Fix Version/s: 2.2 M1
    • Component/s: Core
    • Labels:
      None
    • Environment:
      Java 1.6/1.7, Spring Integration 2.0.5, Spring 3.0.5

      Description

      When I try to define service activator as a chain element using namespace support, exception is raised.
      For example, the following definition does not work:

        <int:chain input-channel="input">
          <int:header-enricher>
            <int:header name="file_name" value="myfile.txt" />
          </int:header-enricher>
          <file:outbound-channel-adapter id="fileWriter" directory="/tmp" />
        </int:chain>
      

      When I do the same using plain bean definition (not using namespaces), everything is fine:

      <int:chain input-channel="input">
          <int:header-enricher>
            <int:header name="file_name" value="myfile.txt" />
          </int:header-enricher>
          <int:service-activator ref="fileWritingMessageHandler"
            method="handleMessage" />
        </int:chain>
      
        <bean id="fileWritingMessageHandler"
          class="org.springframework.integration.file.FileWritingMessageHandler">
          <constructor-arg value="/tmp" />
      
          <property name="fileNameGenerator">
            <bean class="org.springframework.integration.file.DefaultFileNameGenerator">
              <property name="headerName" value="file_name" />
            </bean>
          </property>
          <property name="outputChannel" ref="nullChannel" />
        </bean>
      

      Exactly the same situation is for other activators, for example int-event:outbound-channel-adapter.
      I've enclosed sample maven project reproducing this issue: try to run "FailingTest" and "WorkingTest".

      Exception:

      java.lang.IllegalStateException: Failed to load ApplicationContext
      	at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:308)
      	at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109)
      	at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)
      	at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:321)
      	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:220)
      	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:301)
      	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
      	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:303)
      	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
      	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
      	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
      	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
      	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
      	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
      	at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
      	at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
      	at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
      	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180)
      	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
      	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
      	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
      	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
      	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
      Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.integration.handler.MessageHandlerChain#0': Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'java.util.ArrayList' to required type 'java.util.List' for property 'handlers'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.springframework.integration.endpoint.EventDrivenConsumer] to required type [org.springframework.integration.core.MessageHandler] for property 'handlers[1]': no matching editors or conversion strategy found
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
      	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
      	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
      	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
      	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
      	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
      	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
      	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
      	at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:84)
      	at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:1)
      	at org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:280)
      	at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:304)
      	... 24 more
      Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'java.util.ArrayList' to required type 'java.util.List' for property 'handlers'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.springframework.integration.endpoint.EventDrivenConsumer] to required type [org.springframework.integration.core.MessageHandler] for property 'handlers[1]': no matching editors or conversion strategy found
      	at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:462)
      	at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:499)
      	at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:493)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1371)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1330)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
      	... 36 more
      Caused by: java.lang.IllegalStateException: Cannot convert value of type [org.springframework.integration.endpoint.EventDrivenConsumer] to required type [org.springframework.integration.core.MessageHandler] for property 'handlers[1]': no matching editors or conversion strategy found
      	at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:231)
      	at org.springframework.beans.TypeConverterDelegate.convertToTypedCollection(TypeConverterDelegate.java:520)
      	at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:173)
      	at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:447)
      	... 42 more
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                abilan Artem Bilan
                Reporter:
                p.dyraga Piotr Dyraga
              • Votes:
                1 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: