【问题标题】:java.lang.ClassNotFoundException: org.reactivestreams.Publisher not found when using camelahc componentjava.lang.ClassNotFoundException:使用 camelahc 组件时未找到 org.reactivestreams.Publisher
【发布时间】:2019-08-08 19:42:09
【问题描述】:

我想使用ahc组件调用外部http服务,在pom.xml中添加camel-ahc依赖,并且在karaf中安装camel-ahc功能:

feature:install camel-ahc

已添加的捆绑包:

骆驼-ahc 和 wrap_file__home_ossl_.m2_repository_org_asynchttpclient_async-http-client_2.4.3_async-http-cl...

我的代码是:

    <camelContext id="jetty-ws-camel-ahc" xmlns="http://camel.apache.org/schema/blueprint" >
       <route id="ahc-route">
        <from uri="timer://webinar?period=20000"/> 
              <setHeader headerName="CamelHttpMethod">
                  <constant>GET</constant>
              </setHeader>
          <to uri="ahc:http://217.0.0.0:3030/sendSMS/mynumber/bye"/>
      <log message="message sent!"/>
       </route>
</camelContext>

但是我有一个警告并且请求没有发送到 http 地址: WARN [Blueprint Extender: 3] Listener 引起异常,将被忽略 java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: org/reactivestreams/Publisher

原因:java.lang.ClassNotFoundException: org.reactivestreams.Publisher not found by wrap_file__home_ossl_.m2_repository_org_asynchttpclient_async-http-client_2.4.3_async-http-client-2.4.3.jar_Export-Package_org.asynchttpclient.__version_2.4.3

我该怎么办?

【问题讨论】:

    标签: asynchronous apache-camel apache-karaf


    【解决方案1】:

    问题是工件org.asynchttpclient/async-http-client的自动包装。

    默认情况下,包装使所有 Import-Package 子句都是可选的,这有时会使构建可靠的连接设置变得困难,因为当解析器在查看导出“可选”包的包之前查看包装的包时,它们不会将它们连接在一起,因为它们是可选的,所以即使在微秒后出现,解析器也会很乐意跳过它们。

    要对此进行测试,您可以bundle:refresh &lt;id&gt; async-http-client 包并查看bundle:tree-show &lt;id&gt; 包是否仍未连接(标记为WARNING)。

    为了可靠地修复它,您可以基于官方 Apache Camel 功能创建自己的功能并修改包装以强制某些导入(例如,将 &amp;Import-Package=org.reactivestreams,*;resolution:=optional 附加到 wrap: 语句)。

    还可以查看Wrap Protocol

    【讨论】:

      猜你喜欢
      • 2016-12-03
      • 1970-01-01
      • 2021-05-30
      • 2016-12-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多