当前位置: 首页 > 知识库问答 >
问题:

使用带有REST DSL的camel jetty组件-“component jetty不是restapiconsumerFactory”异常

邬令
2023-03-14

我们用的是骆驼RestDSL。我们让它(通过camel-spring-boot支持)与netty4-http组件一起工作。

相关工作代码/配置如下:

dependencies {
    compile (group: 'org.apache.camel', name: 'camel-spring-boot', version: '2.16.1')
    compile (group: 'org.apache.camel', name: 'camel-netty4-http', version: '2.16.1')
    compile (group: 'org.apache.camel', name: 'camel-jackson', version: '2.16.1')
    compile (group: 'org.apache.camel', name: 'camel-swagger-java', version: '2.16.1')
    compile (group: 'org.apache.camel', name: 'camel-cxf', version: '2.16.1')
    compile (group: 'org.springframework.boot', name: 'spring-boot', version: '1.3.1.RELEASE')
@Component
public class ExampleRestDslRoute extends RouteBuilder {

    @Override
    public void configure() throws Exception {

        restConfiguration()
            .component("netty4-http")
            .bindingMode(RestBindingMode.json)
            .dataFormatProperty("prettyPrint", "true")
            .host("0.0.0.0")
            .contextPath(restApiBaseUrl)
            .port("10000")
            .apiContextPath("/api-doc")
            .apiProperty("api.description", restApiDesc)
            .apiProperty("api.title", restApiTitle)
            .apiProperty("api.version", restApiVersion) 
            .apiProperty("cors", "true");

        rest("/hello").description("Say hello.")
            .produces("application/json")
            .get().description("Get hello.").route().transform(constant("BOOOOOOOM!!!!!"));

    }
compile (group: 'org.apache.camel', name: 'camel-jetty9', version: '2.16.1')
restConfiguration()
            .component("jetty")
12:31:53.805 [main] ERROR o.springframework.boot.SpringApplication - Application startup failed
org.apache.camel.spring.boot.CamelSpringBootInitializationException: java.lang.IllegalArgumentException: Component jetty is not a RestApiConsumerFactory
    at org.apache.camel.spring.boot.RoutesCollector.onApplicationEvent(RoutesCollector.java:87) ~[camel-spring-boot-2.16.1.jar:2.16.1]
    at org.apache.camel.spring.boot.RoutesCollector.onApplicationEvent(RoutesCollector.java:37) ~[camel-spring-boot-2.16.1.jar:2.16.1]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:163) ~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:136) ~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:381) ~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:335) ~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:855) ~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:140) ~[spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541) ~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:764) ~[spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]
    at org.springframework.ringApplication.doRun(SpringApplication.java:357) ~[spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:305) ~[spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]
    at org.apache.camel.spring.boot.FatJarRouter.main(FatJarRouter.java:26) [camel-spring-boot-2.16.1.jar:2.16.1]
Caused by: java.lang.IllegalArgumentException: Component jetty is not a RestApiConsumerFactory
    at org.apache.camel.component.rest.RestApiEndpoint.createConsumer(RestApiEndpoint.java:220) ~[camel-core-2.16.1.jar:2.16.1]
    at org.apache.camel.impl.EventDrivenConsumerRoute.addServices(EventDrivenConsumerRoute.java:68) ~[camel-core-2.16.1.jar:2.16.1]
    at org.apache.camel.impl.DefaultRoute.onStartingServices(DefaultRoute.java:98) ~[camel-core-2.16.1.jar:2.16.1]
    at org.apache.camel.impl.RouteService.warmUp(RouteService.java:158) ~[camel-core-2.16.1.jar:2.16.1]
    at org.apache.camel.impl.DefaultCamelContext.doWarmUpRoutes(DefaultCamelContext.java:3453) ~[camel-core-2.16.1.jar:2.16.1]
    at org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:3383) ~[camel-core-2.16.1.jar:2.16.1]
    at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:3160) ~[camel-core-2.16.1.jar:2.16.1]
    at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3016) ~[camel-core-2.16.1.jar:2.16.1]
    at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:175) ~[camel-core-2.16.1.jar:2.16.1]
    at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2812) ~[camel-core-2.16.1.jar:2.16.1]
    at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2808) ~[camel-core-2.16.1.jar:2.16.1]
    at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2831) ~[camel-core-2.16.1.jar:2.16.1]
    at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:2808) ~[camel-core-2.16.1.jar:2.16.1]
    at org.apache.camel.support.Serport.start(ServiceSupport.java:61) ~[camel-core-2.16.1.jar:2.16.1]
    at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:2777) ~[camel-core-2.16.1.jar:2.16.1]
    at org.apache.camel.spring.boot.RoutesCollector.onApplicationEvent(RoutesCollector.java:85) ~[camel-spring-boot-2.16.1.jar:2.16.1]
    ... 13 common frames omitted

共有1个答案

熊嘉茂
2023-03-14

我们需要升级到camel的2.16.2版本(为此感谢@Clausibsen-参见上面他的评论)。

dependencies {
    compile (group: 'org.apache.camel', name: 'camel-spring-boot', version: '2.16.2')
    compile (group: 'org.apache.camel', name: 'camel-jetty9', version: '2.16.2')
    compile (group: 'org.apache.camel', name: 'camel-jackson', version: '2.16.2')
    compile (group: 'org.apache.camel', name: 'camel-swagger-java', version: '2.16.2')
    compile (group: 'org.apache.camel', name: 'camel-cxf', version: '2.16.2')
    compile (group: 'org.springframework.boot', name: 'spring-boot', version: '1.3.1.RELEASE')
 类似资料:
  • 注意:如果您已经在使用RxJava或Agera这样的库,那么您可以继续使用它们,而不是LiveData。但是当您使用它们或其他方法时,请确保您正确地处理了生命周期,以便在相关的LifecycleOwner停止时数据流暂停,并且在LifecycleOwner被销毁时数据流被销毁。您还可以添加android.arch.lifecycle:reActiveStreams工件,以便将LiveData与另一

  • 我希望上传一个包含一个文件和一些json的多部分文件,并使用camel rest dsl将该文件输出到本地文件夹。 我在路由中使用处理器,使用HttpServletRequest将多部分请求拆分为多个部分。getPart(),但我收到以下错误: 我已经向 servlet 添加了一个多部分筛选器,并且已经尝试了使用和不使用多部分解决方案 Bean。当我调试处理器时,我可以看到 HttpServlet

  • 问题内容: 我试图找出json序列化出了什么问题,将我的应用程序的当前版本与旧版本一起使用,并发现JSON.stringify()的工作方式中存在一些令人惊讶的差异(使用json.org中的JSON库) )。 在我的应用的旧版本中: 给我这个 在新版本中, 给我这个 任何想法都可能会发生什么变化,以使同一库在新版本中在数组括号内加上引号? 问题答案: 由于JSON.stringify最近已经随某些

  • 我试图弄清楚为什么Lettuce会给我带来这么多问题,而我正在运行我的性能测试,将它与Jedis进行比较。 我使用spring-data-redis1.8.11.release,并为通过Redistemplate访问redis的接口创建了自定义代理bean。Redis运行在AWS中,我使用AWS提供的集群配置endpoint作为节点,它有3个主节点和3个从节点。在性能测试过程中没有发生任何特殊情况

  • null 我得到以下错误: 为什么会这样?

  • 问题内容: 我有一个React组件,其中包含一些其他组件,这些组件依赖于对Redux存储等的访问,这会在执行完整的酶安装时引起问题。假设这样的结构: 我想使用Jest的方法来模拟子组件,因此测试无需担心。 我知道我可以通过以下方式模拟出一个简单的组件: 但是,由于该组件通常会接收道具,因此React会感到不安,并发出有关将未知道具(在本例中为)传递给的警告。 我试图返回一个函数,但是由于悬挂了,所