2015-05-29 78 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