Dhruba Swain
Dhruba Swain

Reputation: 1

Spring integration : Http outbaound gateway with Jaxb2RootElementHttpMessageConverter

I have to call external service for different endpoints. there are http-outbound gateways. Each end point accepting different data like json or xml. Below is the configuration to produce/consume xml:

<int-http:outbound-gateway
        id="ca.outbound.gateway" 
        request-channel="ca.request.channel" url-expression="http://localhost:9988/current/acct/create"
        http-method-expression="POST"
        message-converters="Jaxb2RootElementHttpMessageConverter"
        expected-response-type-expression="com.ds.Account"      
        charset="UTF-8" reply-timeout="5000" reply-channel="ca.reply.channel">
</int-http:outbound-gateway>

But while starting the application, getting error like: APPLICATION FAILED TO START

A component required a bean named 'Jaxb2RootElementHttpMessageConverter' that could not be found.

Consider defining a bean named 'Jaxb2RootElementHttpMessageConverter' in your configuration.

Note: Jaxb2RootElementHttpMessageConverter class is present in Classpath Spring-web-5.0.5.RELEASE.jar.

I am not sure how to resolve this error.

Upvotes: 0

Views: 86

Answers (1)

Artem Bilan
Artem Bilan

Reputation: 121177

The error clearly say that you don't have a bean on the matter. The fact that you have a class in classpath doesn't mean that you got a bean for it automatically. You really should declare something like this:

<bean id="jaxb2RootElementHttpMessageConverter" class="org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter"/>

and then use its id as a reference from that message-converters attribute.

Please, consider to learn more about Spring: https://docs.spring.io/spring-framework/docs/current/spring-framework-reference/core.html#spring-core

Upvotes: 3

Related Questions