2

Apache Camel does not seem to support any bean that is to be used within its registry. I am currently trying to add an AWS S3 Client object/bean to the spring configuration without any luck. The bean itself is added to the registry, but when camel goes to use the client object it throws an error similar to this:

Caused by: java.lang.IllegalArgumentException: Could not find a 
suitable setter for property: amazonS3Client as there isn't a setter  method 
with same type: java.lang.String nor type conversion possible: No type 
converter available to convert from type: java.lang.String to the 
required type: com.amazonaws.services.s3.AmazonS3 with value 
#amazonClient

The amazonClient is the aforementioned bean that is added appropriately the spring config which has led me to believe the camel config is indeed finding the bean. Here is the related xml configuration:

<!-- set up default amazon s3 client from amazon aws sdk -->
<bean id="amazonClient" class="com.amazonaws.services.s3.AmazonS3Client">
    <constructor-arg>
        <bean class="com.amazonaws.auth.BasicAWSCredentials">
            <constructor-arg name="accessKey" value=""/>
            <constructor-arg name="secretKey" value=""/>
        </bean>
    </constructor-arg>
</bean>

Within the camel context section (you can see the bean is mentioned):

    <camel:route id="importFilesFromS3">
        <camel:from uri="aws-s3://intuit-commerce-imports?amazonS3Client=#amazonClient&amp;region=us-west-2&amp;deleteAfterRead=true"/>
        <camel:to uri="ref:importProcessingEndpoint"/>
    </camel:route>

Apache camel claims to have this feature in their documentation, but I have found a few sources that come across the same issue. The answer in the link does not provide much explanation.

Community
  • 1
  • 1
Chad Van De Hey
  • 2,716
  • 3
  • 29
  • 46

1 Answers1

0

I've never worked with AWS S3, but I also ran into a similar problem with Camel seemingly not able to find the bean within the Spring registry.

By stepping through IntrospectionSupport.setProperty, I noticed that CamelContextHelper.lookup was using JndiRegistry instead of the ApplicationContextRegistry.

My solution was to add camel-spring as a project dependency, as well as to initialize my camel context with ApplicationContextRegistry:

camelContext = new DefaultCamelContext(new ApplicationContextRegistry(applicationContext));
SP193
  • 156
  • 2
  • 5