2014-01-17 45 views
2

我正在努力获得一个简单的cxf:rsServer来侦听端口。
我appContext:使用camel时,cxf:rsServer是否需要jaxrs:server?

<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> 

我的例外:

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

我的骆驼版本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混淆了HTTP问题和异常

  1. 我以单机运行骆驼,所以我不认为我需要一个Servlet。
  2. pushServer使用TCP://而不是http:/
  3. 变压器是一个POJO和一无所知HTTP

问:In most of the xml examples regarding cxf:rsServer我见过JAXRS:服务器配置。这是我没有的一件事。我需要它吗? 感谢您的阅读。所有建议都欢迎。

安德鲁

+0

我解决了NoClassDef问题,将camel-http添加到了pom中。我仍然想知道cxfrs是否需要jaxrs:server。他们可能不是,但我不知道为什么代码是在我看到的例子中。 – KingAndrew

回答

3

在实施例中示出的是jaxrs:server模拟远程REST web服务以完成路由选择的例子。

  • 路线起点:CXF:rsServer
  • 路线为:CXF:rsClient

的CXF RS客户端需要的地方发送邮件,这是一个不同的端口上运行什么JAX RS服务器是用来。

由于上面的路由目标是别的东西(一个日志组件),您不需要JAX RS服务器配置。

相关问题