Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache camel 驼峰http组件500_Apache Camel - Fatal编程技术网

Apache camel 驼峰http组件500

Apache camel 驼峰http组件500,apache-camel,Apache Camel,我正在创建cxf/camel webservice,并为测试代码创建了如下代码: @GET @Path("/user") @ProduceMime({ "application/json" }) public String user(@FormParam("token") String token) throws Exception { CamelContext context = new DefaultCamelContext(); context.addR

我正在创建cxf/camel webservice,并为测试代码创建了如下代码:

@GET
@Path("/user")
@ProduceMime({ "application/json" })
public String user(@FormParam("token") String token) throws Exception {

        CamelContext context = new DefaultCamelContext();

        context.addRoutes(new RouteBuilder() {
            public void configure(){
                from("direct:start").to("http://google.com");
            }
        });

        context.start();

        return token;

    }

}
然后我编译了它并复制了do FUSE ESB deploy文件夹。我的Web服务已安装,但当我用我的Web服务打开URL时,得到500响应:

  org.apache.cxf.interceptor.Fault: Failed to create route route17 at: >>> To[http://google.com] <<< in route: Route[[From[direct:start]] -> [To[http://google.com]]] because of Failed to resolve endpoint: http://google.com due to: No component found with scheme: http
Caused by:

java.lang.RuntimeException: org.apache.cxf.interceptor.Fault: Failed to create route route17 at: >>> To[http://google.com] <<< in route: Route[[From[direct:start]] -> [To[http://google.com]]] because of Failed to resolve endpoint: http://google.com due to: No component found with scheme: http
    at org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:108)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:323)
    at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
    at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:206)
    at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:209)
    at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:152)
    at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:114)
    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:184)
    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:112)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:575)
    at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:163)
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:538)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:478)
    at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:70)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
    at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:480)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:225)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:937)
    at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:116)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:406)
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:183)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:871)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
    at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:72)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110)
    at org.eclipse.jetty.server.Server.handle(Server.java:346)
    at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:438)
    at org.eclipse.jetty.server.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:905)
    at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:561)
    at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:214)
    at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:43)
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:538)
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:43)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:529)
    at java.lang.Thread.run(Thread.java:680)
在ESB上,我打开了骆驼http

怎么了

--------------
所以我认为我写的是错误的,下面的代码应该正确吗

 <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:osgi="http://www.springframework.org/schema/osgi"
    xmlns:jaxrs="http://cxf.apache.org/jaxrs"
    xmlns:camel="http://camel.apache.org/schema/spring"
    xmlns:cxf="http://camel.apache.org/schema/cxf"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
    http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
    http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd      
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.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">

    <import resource="classpath:META-INF/cxf/cxf.xml" />
    <import resource="classpath:META-INF/cxf/osgi/cxf-extension-osgi.xml" />

    <bean id="cxfSSO" class="com.esb.cxf.SSO" />
    <jaxrs:server id="sso" address="/ssocamel2">
        <jaxrs:serviceBeans>
            <ref bean="cxfSSO" />
        </jaxrs:serviceBeans>
    </jaxrs:server>

      <camelContext xmlns="http://camel.apache.org/schema/spring">

        <endpoint id="endpointURL" uri="http://localhost:8080/SSO/?token=test"/>

        <route>
          <from uri="direct:start"/>
          <to uri="callRealWebService"/>
        </route>

      </camelContext>



</beans>

两件事,“scheme:http中找不到组件”意味着您在包中缺少camel-http依赖项

接下来,您应该设置骆驼上下文/路由一次…而不是在这样的方法调用中

两件事,“scheme:http中找不到组件”意味着您缺少捆绑包中的camel-http依赖项


接下来,您应该设置骆驼上下文/路由一次…而不是在这样的方法调用中

您需要安装camel http功能。从Fuse ESB控制台,您可以键入:

features:install camel-http
然后,您可以安装/启动捆绑包


正如本所说,你在rest服务中所做的是完全错误的。您应该设置骆驼路线一次。如果希望使用Camel从Java代码调用http端点,则不需要路由,但可以使用ProducerTemplate。有关更多详细信息,请参阅Camel文档。

您需要安装Camel http功能。从Fuse ESB控制台,您可以键入:

features:install camel-http
然后,您可以安装/启动捆绑包


正如本所说,你在rest服务中所做的是完全错误的。您应该设置骆驼路线一次。如果希望使用Camel从Java代码调用http端点,则不需要路由,但可以使用ProducerTemplate。有关更多详细信息,请参阅Camel文档。

我将检查捆绑包,但我记得我的捆绑包中有Camel http,我会检查。大约秒-正如ApacheCamel网站所示,我可以使用
from(“direct:start”).setHeader(Exchange.HTTP_URI,simple()http://myserver/orders/${header.orderId}”))。到(“http://dummyhost");。如果我可以使用这样的东西,为什么我不能在任何方法中使用它呢?从一个方法中,你可以调用一个路由(template.send(“direct:start”,message)等),而不是定义路由本身……请看,我将检查捆绑包,但我记得我的捆绑包中有驼峰http——我会检查。大约秒-正如ApacheCamel网站所示,我可以使用
from(“direct:start”).setHeader(Exchange.HTTP_URI,simple()http://myserver/orders/${header.orderId}”))。到(“http://dummyhost");。如果我可以使用这样的东西,为什么我不能在任何方法中使用它呢?从一个方法中,你可以调用一个路由(template.send(“direct:start”,message)等),而不是定义路由本身…请看OK,所以我将尝试用xml做所有事情-我在下面添加的代码是否正确?因为我运行了这个应用程序,但我看不出它在工作…:(@Clauslbsen我也有同样的问题,你能建议我如何解决这个问题吗。好的,那么我将尝试用xml做所有的事情-我在下面添加的代码是不是正确的
-->
?因为我运行这个应用程序,但我看不到它在工作…:(@Clauslbsen我也有同样的问题,你能建议我如何解决这个问题吗。