如何:osgi和共享软件包? [英] Howto: osgi and shared packages?

查看:104
本文介绍了如何:osgi和共享软件包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个应该使用org.elasticsearch.client.RestHighLevelClient的osgi应用程序. 为此,我添加了捆绑包servicemix.bundles.elasticsearch-client,因为它导出了 org.elasticsearch.client 和所需的 RestHighLevelClient .不过显然, RestHighLevelClient 需要servicemix.bundles.elasticsearch(以及其他功能)才能正常工作,所以我还要添加它-两个版本都相同.这两个捆绑包均导出 org.elasticsearch.client ,但内容不同. 一切都按预期加载,我可以验证导出的软件包.

Im trying to write an osgi-application that should make use of the org.elasticsearch.client.RestHighLevelClient. For this I have added the bundle servicemix.bundles.elasticsearch-client since it exports org.elasticsearch.client with the needed RestHighLevelClient. Apparently though, it seems that the RestHighLevelClient needs servicemix.bundles.elasticsearch (amongst others) to work so I add that aswell - both of the same version. Both of the bundles export org.elasticsearch.client but with different content. Everything loads as expected and I can verify the exported packages.

编辑: 该问题使我自己重新感到自己是 org.elasticsearch.client.RestHighLevelClient 的ClassNotFound例外.这很奇怪,因为我可以看到elasticsearch-client可用并导出所需的程序包.

EDIT: The problem that im getting reviels it self as a ClassNotFound-exception for org.elasticsearch.client.RestHighLevelClient. Which is odd since I can view that the elasticsearch-client is available and exporting the requred package.

我的解释是,Karaf确实能够处理共享软件包.它似乎加载了具有所需程序包的捆绑软件之一,以满足我的应用程序功能的要求,然后,即使所需的类实际上存在于另一个捆绑软件中,也决定它足够了.

My interpretation is that Karaf doesent seem to be able to handle shared packages. It seem to load one of the bundles that have the required package to suffice the requirement from my application-feature, and after that decides that it is enough even though the needed class actually exist in the the other bundle.

在@ChristianSchneider发表评论并获得更多了解之后,我已经更新了我的配置.但是,问题仍然存在.

After comments from @ChristianSchneider and gaining some more understanding I have updated my configuration. However, the issue still remains.

我现在具有elastisearch-client6功能和elasticsearch6-feature

I now have a elastisearch-client6-feature and an elasticsearch6-feature

   
    <feature name="elasticsearch6" version="6.3.2" description="Elasticsearch Base libraries">
        <bundle start-level="80">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch/6.3.2_1</bundle>
        <bundle dependency="true">mvn:com.fasterxml.jackson.dataformat/jackson-dataformat-cbor/2.9.6</bundle>
        <bundle dependency="true">mvn:com.fasterxml.jackson.core/jackson-core/2.9.6</bundle>
        <bundle dependency="true">wrap:mvn:com.vividsolutions/jts/1.13</bundle>
        <bundle dependency="true">wrap:mvn:io.sgr/s2-geometry-library-java/1.0.0</bundle>
        <bundle dependency="true"><![CDATA[wrap:mvn:io.netty/netty-all/4.1.28.Final$Bundle-Version=4.1.28&Export-Package=*;version=4.1.28]]></bundle>
        <bundle dependency="true">wrap:mvn:org.locationtech.jts/jts-core/1.15.1</bundle>
    </feature>

    <feature name="elasticsearch-client6" version="6.3.2" description="Elasticsearch Client libraries">
        <bundle start-level="80">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch-client/6.3.2_1</bundle>
    </feature>

和我的应用程序功能


    <feature name="my-application" version="${version}">
        <bundle start-level="92">mvn:com.mycompany/application-feature/${version}</bundle>
    </feature>

请问有人可以建议我如何强制我的应用程序功能同时加载elasticsearch-client6-feature和elasticesearch6.

Can someone please suggest how I force my application-feature to both load the elasticsearch-client6-feature aswell as elasticesearch6 as they are both required.

亲切的问候 Jiinx

Kind regards Jiinx

推荐答案

我遇到了同样的问题,这就是我所做的...

I had the same problem and this is what I did...

  1. 转到 https ://jar-download.com/artifacts/org.elasticsearch.client/elasticsearch-rest-high-level-client/all-versions ,该网站可让您下载Maven工件及其所有依赖项,选择所需的版本.
  2. 选择版本后,单击红色下载按钮,它将下载包含所有弹性搜索jar和所需依赖项的zip文件.下载后,将jar解压缩到本地文件系统上.
  3. 创建一个包,如com.mycompany.thirdparty.elasticsearch
  4. 在分发包的根目录中创建一个lib文件夹,然后将所有从下载中解压缩的jar文件复制/粘贴到该文件夹​​中.
  5. 使用eclipse MANIFEST编辑器转到运行时选项卡",在类路径"部分中,将所有jar都添加到lib文件夹中.然后,对于导出的软件包,单击添加并添加所有可用的软件包.
  1. Go to https://jar-download.com/artifacts/org.elasticsearch.client/elasticsearch-rest-high-level-client/all-versions which is a site that lets you download maven artifacts as well as all their dependencies, select the version you want.
  2. After selecting the version click the red download button and it will download a zip file with all the elastic search jars and required dependencies.After downloading unzip the jar on your local file system.
  3. Create a bundle like com.mycompany.thirdparty.elasticsearch
  4. Create a lib folder in the root of the bundle and copy/paste all those jars you unzipped from the download into that folder.
  5. Using eclipse MANIFEST editor go to Runtime Tab, in the class path section add all the jars in the lib folder. Then for exported packages click add and add all the packages available.

这将创建一个具有弹性搜索及其所有依赖项的捆绑软件,这些捆绑软件将导出到导入弹性搜索包或将该捆绑软件添加为依赖项的其他捆绑软件中.

This creates a bundle that has elastic search and all its dependencies which are exported to other bundles that import elastic search packages or add the bundle as a dependency.

希望能为您提供正确的方向,最容易在MANIFEST编辑器中实现,因为它会自动更新build.properties文件.

Hope that gets you in the right direction, its easiest to do this in eclipse with the MANIFEST editor because it automatically updates build.properties files.

这篇关于如何:osgi和共享软件包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆