2015-05-29 77 views
1

我试图开发一个休息服务并通过Apache Camel的CXFRS公开相同的服务。我遵循了http://camel.apache.org/cxfrs.html中给出的所有步骤,并且还提到了许多样本。我已经提到了Can't find the the request for url Observer的问题,但在我的情况下,这是一个简单的休息请求。下面是服务类,Route类和CXF上下文中使用:Apache camel cxfrs-无法找到<URL>的请求观察者

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xmlns:camel="http://camel.apache.org/schema/spring" 
xmlns:cxf="http://camel.apache.org/schema/cxf" xmlns:context="http://www.springframework.org/schema/context" 
xmlns:jaxrs="http://cxf.apache.org/jaxrs" 

    xsi:schemaLocation="http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans.xsd 
    http://camel.apache.org/schema/spring 
    http://camel.apache.org/schema/spring/camel-spring.xsd 
    http://camel.apache.org/schema/cxf 
    http://camel.apache.org/schema/cxf/camel-cxf.xsd 
    http://www.springframework.org/schema/context 
    http://www.springframework.org/schema/context/spring-context.xsd 
    http://cxf.apache.org/jaxrs 
    http://cxf.apache.org/schemas/jaxrs.xsd"> 

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

<!-- enable Spring @Component scan --> 
<context:component-scan base-package="org.camelsample.rest" /> 

<cxf:rsServer id="rsServer" address="/rest" 
    serviceClass="org.camelsample.rest.service.SampleRestService" 
    loggingFeatureEnabled="true" loggingSizeLimit="20"> 
    <cxf:providers> 
     <bean class="org.codehaus.jackson.jaxrs.JacksonJsonProvider" /> 
    </cxf:providers> 
</cxf:rsServer> 

<camel:camelContext id="samplerestservice" 
    xmlns="http://camel.apache.org/schema/spring"> 
    <contextScan /> 
    <jmxAgent id="agent" createConnector="true" /> 
</camel:camelContext> 

</beans> 

服务类:

package org.camelsample.rest.service; 

import javax.ws.rs.GET; 
import javax.ws.rs.Path; 

public class SampleRestService { 

    @GET 
    @Path("/") 
    public String sampleService() { 
     return null; 
    } 
} 

Route类:

package org.camelsample.rest.route; 

import org.apache.camel.spring.SpringRouteBuilder; 

public class SampleRestRoute extends SpringRouteBuilder { 

    @Override 
    public void configure() throws Exception { 
     // TODO Auto-generated method stub 
     from("cxfrs:bean:rsServer").log("Into Sample Route").setBody(constant("Success")); 
    } 
} 

但是,当我试着打和使用http://localhost:8080/rest进行测试,我总是得到以下错误信息:

2015-05-29 13:38:37.920 WARN 6744 --- [nio-8080-exec-2] o.a.c.t.servlet.ServletController  : Can't find the the request for http://localhost:8080/favicon.ico's Observer 
2015-05-29 13:38:40.295 WARN 6744 --- [nio-8080-exec-3] o.a.c.t.servlet.ServletController  : Can't find the the request for http://localhost:8080/rest's Observer 

我正在使用Spring引导来测试其余示例。

回答

0

它是否与这个URL一起使用?

http://localhost:8181/cxf/rest 

如果只是用address="/rest"你的地址,那么你可能会得到默认的码头港口8181和默认CXF servlet路径/cxf基础网址。

如果你特别想用你给的网址,然后试试这个:

address="http://0.0.0.0:8080/rest" 
+0

试图同其仍然没有工作。抛出相同的错误 – Guru

+0

我有一个类似的问题,它在没有结构的情况下工作,并且在结构上失败。 – bwfrieds