user1627943
user1627943

Reputation: 337

Apache Camel: Route from camel tomcat servlet to cxfbean component

Problem Description: I am failing to route from my camel servlet to a cxfbean. Route initialization fails with the following error message:

"Failed to create route route1 at: >>> To[cxfbean:fooEndpoint] <<< in route:
 Route[[From[servlet:///?servletName=BwsServlet]] -> [To[cxfb... because of Failed to resolve 
 endpoint: cxfbean://fooEndpoint due to: null".

The servlet starts fine without the cxfbean.

UPDATED: Please note that I intend to use a Camel Cxf Bean Component as opposed to a Camel Cxf Bean.

What I want to achieve: I am running a camel servlet within Tomcat. I have a bean which implements my webservice interface (generated from WSDL by CXF). I want to process the XML message bodies before passing them on to this webservice bean. I would like to use cxf bean component as opposed to a cxf endpoint bean, since I do not want to have my cxf endpoint listen on a network port in addition to the already running camel servlet.

How my code looks like: My camel-config.xml looks like this:

<bean id="bwsRouteBuilder" class="local.com.foo.BwsRouteBuilder"/>
<bean id="fooEndpoint" class="local.com.foo.FooBws"/>
<camel:camelContext id="bws">
    <camel:routeBuilder ref="bwsRouteBuilder"/>
</camel:camelContext>

My route builder (written in Java DSL) looks like this:

public void configure() throws Exception {
    from("servlet:///?servletName=BwsServlet")
    // some processing of message here
    .to("cxfbean:fooEndpoint");
}

UPDATED: Note the cxfbean URI format in the above code as defined here.

My web.xml looks like this:

<servlet>
    <servlet-name>BwsServlet</servlet-name>
    <servlet-class>org.apache.camel.component.servlet.CamelHttpTransportServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>BwsServlet</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>

camel-cxf is included as dependency in my pom.xml.

Where I looked at so far for help: I was following the documentation at Apache Camel cxfbean description and followed stackoverflow. I hope my question is not a no-brainer to answer, I am new to Camel.

Many thanks in advance for your thoughts

Upvotes: 4

Views: 2015

Answers (1)

cexbrayat
cexbrayat

Reputation: 18442

If you want to use a cxf bean you have to write "cxf:bean:fooEndpoint" in your route (you have forget : between cxf and bean).

public void configure() throws Exception {
    from("servlet:///?servletName=BwsServlet")
    // some processing of message here
    .to("cxf:bean:fooEndpoint");
}

Upvotes: -1

Related Questions