【问题标题】:Apache camel cxfrs—Can't find the request for <URL> ObserverApache camel cxfrs - 找不到 <URL> Observer 的请求
【发布时间】:2015-08-12 00:48:00
【问题描述】:

我尝试开发一个休息服务并通过 Apache Camel 的 CXFRS 公开它。我遵循了http://camel.apache.org/cxfrs.html 中给出的所有步骤,并且还参考了给出的许多示例。我已经提到了问题Can't find the the request for url Observer,但就我而言,这是一个简单的休息请求。下面是使用的 Service 类、Route 类和 cxf 上下文:

<?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;
    }
}

路线类:

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 boot 测试其余示例。

【问题讨论】:

    标签: rest apache-camel jax-rs cxfrs


    【解决方案1】:

    它是否适用于这个 URL?

    http://localhost:8181/cxf/rest
    

    如果您只使用address="/rest" 作为您的地址,那么您可能会得到默认的 Jetty 端口 8181 和默认的 CXF servlet 路径 /cxf 作为基本 URL。

    如果您特别想使用您提供的 URL,请尝试以下方法:

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

    【讨论】:

    • 试过了,还是不行。抛出同样的错误
    • 我也有类似的问题,它在没有面料的情况下工作,在面料上失败。
    猜你喜欢
    • 2017-03-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-21
    • 1970-01-01
    • 2014-12-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多