问题描述:

I am trying to invoke a advice from a service activator I am getting below exception

 <?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns:int="http://www.springframework.org/schema/integration"

xmlns:int-aws="http://www.springframework.org/schema/integration/aws"

xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd

http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd

http://www.springframework.org/schema/integration/aws http://www.springframework.org/schema/integration/aws/spring-integration-aws-1.0.xsd">

<int:poller fixed-delay="${fixedDelay}" default="true"/>

<bean id="credentials" class="org.springframework.integration.aws.core.BasicAWSCredentials">

<property name="accessKey" value="${accessKey}"/>

<property name="secretKey" value="${secretKey}"/>

</bean>

<!-- aws-endpoint="https://s3.amazonaws.com" proxyHost="proxy.kdc.capitalone.com" proxyPort="8099"-->

<bean id="clientConfiguration" class="com.amazonaws.ClientConfiguration">

<property name="proxyHost" value="${proxyHost}"/>

<property name="proxyPort" value="${proxyPort}"/>

<property name="preemptiveBasicProxyAuth" value="false"/>

</bean>

<bean id="s3Operations" class="org.springframework.integration.aws.s3.core.CustomC1AmazonS3Operations">

<constructor-arg index="0" ref="credentials"/>

<constructor-arg index="1" ref="clientConfiguration"/>

<property name="awsEndpoint" value="s3.amazonaws.com"/>

<property name="temporaryDirectory" value="${temporaryDirectory}"/>

<property name="awsSecurityKey" value="${awsSecurityKey}"/>

</bean>

<!-- aws-endpoint="https://s3.amazonaws.com" -->

<int-aws:s3-inbound-channel-adapter aws-endpoint="s3.amazonaws.com"

bucket="${bucket}"

s3-operations="s3Operations"

credentials-ref="credentials"

file-name-wildcard="${fileNameWildcard}"

remote-directory="${remoteDirectory}"

channel="splitChannel"

local-directory="${localDirectory}"

accept-sub-folders="false"

delete-source-files="true"

archive-bucket="${archiveBucket}"

archive-directory="${archiveDirectory}">

</int-aws:s3-inbound-channel-adapter>

<int:service-activator ref="expressionAdvice" input-channel="splitChannel" requires-reply="false"/>

<bean id="expressionAdvice" class="org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice">

<property name="onSuccessExpression" value="payload.delete()" />

</bean>

<int:splitter input-channel="splitChannel" output-channel="output"

expression="T(org.apache.commons.io.FileUtils).lineIterator(payload)">

<int:request-handler-advice-chain>

<bean class="org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice">

<property name="onSuccessExpression" value="payload.delete()"/>

</bean>

</int:request-handler-advice-chain>

</int:splitter>

<int:channel id="output"/>

</beans>


2015-12-22T13:42:26-0600 1.2.1.RELEASE WARN DeploymentsPathChildrenCache-0 annotation.AnnotationConfigApplicationContext - Exception encountered during context initialization - cancelling refresh attempt

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.integration.config.ConsumerEndpointFactoryBean#0': Cannot resolve reference to bean 'org.springframework.integration.config.ServiceActivatorFactoryBean#0' while setting bean property 'handler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.integration.config.ServiceActivatorFactoryBean#0': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumentException: Found ambiguous parameter type [interface org.springframework.expression.Expression] for method match: [public final void org.springframework.integration.context.IntegrationObjectSupport.afterPropertiesSet(), public void org.springframework.integration.context.IntegrationObjectSupport.setChannelResolver(org.springframework.messaging.core.DestinationResolver), public void org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice.setExpressionOnFailure(org.springframework.expression.Expression), public void org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice.setTrapException(boolean), public void org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice.setFailureChannel(org.springframework.messaging.MessageChannel), public final void org.springframework.integration.context.IntegrationObjectSupport.setBeanFactory(org.springframework.beans.factory.BeanFactory), public void org.springframework.integration.context.IntegrationObjectSupport.setApplicationContext(org.springframework.context.ApplicationContext) throws org.springframework.beans.BeansException, public final java.lang.Object org.springframework.integration.handler.advice.AbstractRequestHandlerAdvice.invoke(org.aopalliance.intercept.MethodInvocation) throws java.lang.Throwable, public void org.springframework.integration.context.IntegrationObjectSupport.setComponentName(java.lang.String), public void org.springframework.integration.context.IntegrationObjectSupport.setMessageBuilderFactory(org.springframework.integration.support.MessageBuilderFactory)]

at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]

at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1477) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1222) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]

at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]

网友答案:

I'd say that this design is a bit strange. The ExpressionEvaluatingRequestHandlerAdvice is for the <request-handler-advice-chain> as a sub-elemen of <service-activator>:

<file:outbound-channel-adapter channel="appendToFileChannel"
                               filename-generator-expression="headers.file_name"
                               mode="APPEND"
                               directory="/foo">
    <file:request-handler-advice-chain>
        <bean class="org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice">
            <property name="onSuccessExpression" value="payload.delete()"/>
        </bean>
    </file:request-handler-advice-chain>
</file:outbound-channel-adapter>

Please, consult, Reference Manual for more information.

相关阅读:
Top