Search code examples
restjax-wsjax-rsapache-camelcxfrs

Is jaxrs:server required for cxf:rsServer when using camel?


I'm struggling to get a simple cxf:rsServer to listen on a port.
My appContext:

<bean id="transformer" class="com.xyxx.portlistener.services.Transformer">
</bean> 

<cxf:rsServer id="pushServer" 
              address="tcp://localhost:9090/hrm/hrm_push?bindingStyle=SimpleConsumer;resourceClasses=com.xyxx.portlistener.services.Transformer" >
    <cxf:serviceBeans>
        <ref bean="transformer" />
    </cxf:serviceBeans>
</cxf:rsServer>          

<!--  Camel Configuration -->
<camel:camelContext id="camel-1"  xmlns="http://camel.apache.org/schema/spring">
    <package>com.xyxx.portlistener.services</package> 
    <camel:route id="route1">
           <camel:from uri="cxfrs://bean://pushServer"/> 
           <camel:to uri="log:TEST?showAll=true" />
    </camel:route>            
</camel:camelContext>

My exception:

MethodInvocationException: Property 'serviceBeans' threw exception; nested exception is java.lang.NoClassDefFoundError: javax/servlet/http/HttpServletRequest

My camel version 2.4.0 pom.xml:

        <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-core</artifactId>
        <version>${camel.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-jms</artifactId>
        <version>${camel.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-hl7</artifactId>
        <version>${camel.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-mina</artifactId>
        <version>${camel.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-spring</artifactId>
        <version>${camel.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-cxf</artifactId>
        <version>${camel.version}</version>
    </dependency>

3 confusing issues with HTTP and that exception

  1. I'm running camel as standalone so I don't think I need a Servlet.
  2. pushServer is using tcp:// not http:/
  3. transformer is a pojo and knows nothing about HTTP

Question: In most of the xml examples regarding cxf:rsServer I've seen jaxrs:server configured. That is one thing I do not have. Do I need it? Thanks for reading. All suggestions are welcome.

Andrew


Solution

  • The jaxrs:server shown in the examples is simulating a remote REST web service to complete the routing example.

    • Route From: cxf:rsServer
    • Route To: cxf:rsClient

    The CXF RS client needs to send the message somewhere, which is what the JAX RS server running on a different port is used for.

    Since your route destination above is something else (a log component) you have no need for the JAX RS server configuration.