I'm trying to build a Spring XD (Spring Integration DSL based) sink module using the spring-integration-aws extension. My module looks like so:
@Configuration
@EnableIntegration
public class S3Module {
@Value("${accessKey:myAccessKey}")
private String accessKey;
@Value("${secretKey:mySecretKey}")
private String secretKey;
@Value("${bucket:myBucket}")
private String bucket;
@Value("${remoteDirectoryExpression:dir}")
private String remoteDirectoryExpression;
@Bean
public AmazonS3MessageHandler handle() {
AWSCredentials credentials = new BasicAWSCredentials(this.accessKey, this.secretKey);
AmazonS3MessageHandler handler = new AmazonS3MessageHandler(credentials, new DefaultAmazonS3Operations(credentials));
handler.setBucket(bucket);
handler.setRemoteDirectoryExpression(new LiteralExpression(remoteDirectoryExpression));
return handler;
}
@Bean
public IntegrationFlow flow() {
return IntegrationFlows.from("input")
.handle(handle())
.get();
}
}
I can successfully package up the module and deploy it. When trying to create the stream with:
xd:>stream create --name s3test --definition "file --outputType=text/plain --dir='/tmp/logs' | s3" --deploy
I get the following exception:
00:25:28,850 1.1.0.RC1 INFO DeploymentSupervisor-0 server.StreamDeploymentListener - Deployment status for stream 's3test': DeploymentStatus{state=failed,error(s)=org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flow' defined in com.test.xd.S3Module: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.integration.dsl.IntegrationFlow]: Factory method 'flow' threw exception; nested exception is java.lang.ClassCastException: com.sun.proxy.$Proxy145 cannot be cast to org.springframework.integration.aws.s3.AmazonS3MessageHandler
...
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.integration.dsl.IntegrationFlow]: Factory method 'flow' threw exception; nested exception is java.lang.ClassCastException: com.sun.proxy.$Proxy145 cannot be cast to org.springframework.integration.aws.s3.AmazonS3MessageHandler
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
... 36 more
Caused by: java.lang.ClassCastException: com.sun.proxy.$Proxy145 cannot be cast to org.springframework.integration.aws.s3.AmazonS3MessageHandler
at com.test.xd.S3Module$$EnhancerBySpringCGLIB$$8623ddbe.handle(<generated>)
at com.test.xd.S3Module.flow(S3Module.java:49)
at com.test.xd.S3Module$$EnhancerBySpringCGLIB$$8623ddbe.CGLIB$flow$1(<generated>)
at com.test.xd.S3Module$$EnhancerBySpringCGLIB$$8623ddbe$$FastClassBySpringCGLIB$$3453fd21.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:309)
at com.test.xd.S3Module$$EnhancerBySpringCGLIB$$8623ddbe.flow(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
... 37 more
I'm fairly certain I'm missing something simple. Can someone point me in the right direction? Thanks in advance!