CamelContext(wsBlueprintContext) due Already a destination on

403 views Asked by At

When I try to start my osgi bundle it fails for error ...

14:06:46,086 | ERROR | l Console Thread | BlueprintCamelContext            | 234 - org.apache.camel.camel-blueprint - 2.17.0.redhat-630187 | Error occurred during starting Camel: CamelContext(wsBlueprintContext) due Already a destination on http://hostDomainName:80/cxf/sentence java.lang.RuntimeException: Already a destination on http://hostDomainName:80/cxf/sentence
at org.apache.cxf.transport.http.DestinationRegistryImpl.addDestination(DestinationRegistryImpl.java:50)

Here is a code snippet from the blueprint xml file ...

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
       xmlns:camel="http://camel.apache.org/schema/blueprint"
       xmlns:cxf="http://cxf.apache.org/blueprint/core" 
       xmlns:camelcxf="http://camel.apache.org/schema/blueprint/cxf"
       xmlns:jaxws="http://cxf.apache.org/blueprint/jaxws" 
       xmlns:http-conf="http://cxf.apache.org/transports/http/configuration"
       xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
       xsi:schemaLocation="
       http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd 
       http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd 
   http://cxf.apache.org/blueprint/core http://cxf.apache.org/schemas/blueprint/core.xsd
   http://camel.apache.org/schema/blueprint/cxf http://camel.apache.org/schema/blueprint/cxf/camel-cxf.xsd
   http://cxf.apache.org/blueprint/jaxws http://cxf.apache.org/schemas/blueprint/jaxws.xsd
   http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd 
   http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.0.0.xsd">

<camelcxf:cxfEndpoint id="sentenceEndpoint"
                      loggingFeatureEnabled="true" address="{{sentenceHttpAddress}}"
                      serviceClass="gov.mcjn.it.sentence.ws._interface._1_0.SentenceInterface">
    <camelcxf:features>
        <wsa:addressing xmlns:wsa="http://cxf.apache.org/ws/addressing" />
    </camelcxf:features>
</camelcxf:cxfEndpoint>

<camelcxf:cxfEndpoint id="sentenceResponseEndpoint"
                      loggingFeatureEnabled="true" address="{{sentenceResponseHttpAddress}}"
                      serviceClass="gov.ojp.it.commonresponse._1_0.ws.receivingagency.ResponseInterface">
    <camelcxf:features>
        <wsa:addressing xmlns:wsa="http://cxf.apache.org/ws/addressing" />
    </camelcxf:features>
</camelcxf:cxfEndpoint>

<camelContext trace="true" id="wsBlueprintContext"
              xmlns="http://camel.apache.org/schema/blueprint">
    <route id="cxfSentenceService">
        <from uri="cxf:bean:sentenceEndpoint" />
        <removeHeaders pattern="Expect" />
        <inOnly uri="activemq:incomingSentence?jmsMessageType=Object" />
        <bean ref="sentenceResponseProcessor" />
    </route>
    <route id="cxfSentenceResponseService">
        <from uri="cxf:bean:sentenceResponseEndpoint" />
        <removeHeaders pattern="Expect" />
        <inOnly
            uri="activemq:incomingSentenceResponse?jmsMessageType=Object" />
        <process ref="sentenceAsyncResponseProcessor" />
    </route>        

This snippet is from my properties file...

sentenceResponseHttpAddress=http://hostDomainName/cxf/sentence/response
sentenceHttpAddress=http://hostDomainName/cxf/sentence

CXF seems to think that I am using the same endpoint twice, but I disagree. These endpoints work fine in Fusesource ESB v1. I'm trying to migrate them to JBoss Fuse 6.3 now. To simplify testing and deployments, I am first deploying to a stand-alone karaf container, so Fabric (fabric8) has not been applied yet.

Update: I tried changing <camelcxf:cxfEndpoint> to <jaxws:client> but that caused a different error. In that new error, camel is expecting a CxfEndpoint type but instead got a Proxy object. I really don't want to change the endpoints to fix this issue. I'm certain I have not yet found the two places where the same endpoint is being used. Still searching for that.

Update: I have confirmed that the URI address is not being used twice. It now seems that my entire <camelContext> is getting loaded more than once, even though I have only configured one osgi feature in the repository to use the osgi bundle.

1

There are 1 answers

0
bwfrieds On BEST ANSWER

I found the issue by putting a unique id on the camelContext and watching the logs for that id. An earlier error [java.nio.channels.UnresolvedAddressException] was causing the camel context to shutdown and then restart. During the restart it would try to reload while the previous load was still in memory.

Moral of the story: Get your property values correct in your cfg files because a host name that fails to resolve in DNS will cause your camel context to shutdown and then restart with a misleading error message.

Better yet, just use relative endpoints instead of fully qualified ones.