dnzdlklc
dnzdlklc

Reputation: 55

CamelContext with Spring

I'm having some kind of configuration problem with my camel-server.xml and and Spring integration.

I created a file called camel-server.xml which contains the routes, beans, and other import statements which Camel requires when running deploying the application using SpringBoot.

However, I have this strange error that says:

Caused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [org.apache.camel.CamelContext] is defined: expected single matching bean but found 2: camel-server,camelContext

I don't really understand why Spring is finding two beans as I think I'm only declaring one. See my 'camel-server.xml' below.

<!-- CXF Spring Config -->
<import resource="classpath:META-INF/spring/cxf-server.xml" />

<!--  Bridge Spring property placeholder with Camel, using Archaius as the Source
You must NOT use the <context:property-placeholder> at the same time, only this bridge bean -->
<bean id="properties" class="com.capgemini.archaius.spring.ArchaiusBridgePropertyPlaceholderConfigurer">
    <!-- This must come before the locations -->
    <property name="ignoreResourceNotFound" value="true" />
    <property name="initialDelayMillis" value="1000" />
    <property name="delayMillis" value="1000" />
    <property name="ignoreDeletesFromSource" value="false" />
    <property name="locations">
        <list>
            <value>classpath:/META-INF/spring/lrit-emsa-asp-activemq.properties</value>
            <value>classpath:/META-INF/spring/lrit-emsa-asp-camel.properties</value>
        </list>
    </property>
</bean>

<!-- CamelContext -->
<camelContext id="camel-server" trace="true" xmlns="http://camel.apache.org/schema/spring">
    <camel:jmxAgent id="camel-server-jmx" createConnector="true" connectorPort="9004"/>
    <camel:routeBuilder ref="xxxRoute" />
</camelContext>

<!-- Service Activator Spring Beans -->
<!-- All Service Activator spring beans are located in and annotated with @Component -->
<!-- Additionally, these beans have @Profile annotations indicating when they should be enabled. -->
<!-- Those annotated "default" will always be turned on, unless another bean with the same id (value) is turned on. -->
<!-- To enable a profile, add -Dspring.profiles.active="profile, names, here" to the startup command line -->
<context:component-scan base-package="xxx.yyy.zzz.serviceactivator" />

<!-- Spring Boot Starter Bean -->
<bean id="application" class="xxx.yyy.zzz.Application" />

<!-- Routes -->
<bean id="xxxRoute" class="xxx.yyy.zzz.route.XXXRoute"/>

<!-- Transformers -->
<bean id="pollingRequestTransformer" class="xxx.yyy.zzz.bean.pollingrequest.PollingRequestTransformer"/>

My CXF Server XML is as follows:

<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />

<cxf:cxfEndpoint    id="xyzPortType"
                    address="${xxx.yyy.services.soap.endpoint}"
                    wsdlURL="src/main/resources/META-INF/wsdl/ASP-DC.wsdl"
                    serviceClass="xxx.yyy.zzz.asp.wsdl.XyzPortTypeType"
                    serviceName="xxx:xxxService"
                    xmlns:xxx="http://yzs.abc.org/XML/xxx/2008">

    <cxf:properties>
        <entry key="dataFormat" value="PAYLOAD"/>
        <entry key="loggingFeatureEnabled" value="true"/>
    </cxf:properties>

</cxf:cxfEndpoint>

Upvotes: 0

Views: 5552

Answers (2)

prateek mehta
prateek mehta

Reputation: 171

Use Jboss fuse Integration in your Camel project, you can create spring project using existing template without worrying about integration issues.

Upvotes: 0

dnzdlklc
dnzdlklc

Reputation: 55

That was it! Thank you removed @EnableAutoConfiguration from my Application class and it only looked at my camer-server.xml.

Upvotes: 1

Related Questions