繁体   English   中英

向RCP4项目添加非OSGI罐

[英]Adding non-osgi jars to RCP4 project

我有以下情况。 我依靠一个名为foo.jar的3rd party jar。 该jar具有许多非osgi依赖性。 我创建了一个新项目“从现有JAR归档文件中插入”,选择了所有foo.jars非osgi依赖项,并将其导出为名为“ foo.libs.jar”的“可部署的插件和片段”。

我的RCP4项目是基于功能的产品。 在我的主要RCP项目中,我转到目标文件,导航到“内容”选项卡,并选中foo.jar和foo.libs.jar。 然后,我进入项目文件并选择“验证”,并收到消息“未检测到问题”。

任何提示我在做什么错或需要做些什么才能使它起作用? 我是否必须将foo.libs.jar显式设置为foo.jar的依赖项? 我已经尝试在主项目的manifest-> dependency选项卡和runConfigurations-> Plug-ins中执行此操作,并将foo.libs.jar添加到feature.xmls-> Included插件选项卡中,但似乎没有上班。

谢谢!

===更新===

我认为我的问题可能属于捆绑包碎片和嵌入式依赖项的情况。 举个例子:

- I create foo.libs.jar. One of the jars inside it is activemq.jar 
  I need access to javax.jms.ExceptionListener
- The manifest for foo.libs.jar contains activemq.jar in the 
  Bundle-ClassPath, and javax.jms in the Export-Package sections
- foo.jar contains foo.libs.jar in its Class-Path. It contains  
  javax.jms in its Import-Package and Export-Package sections
- I created a "Plug-in from existing JAR archives" project which has
  foo.jar and foo.libs.jar in it.
- The manifest for the project has foo.jar and foo.libs.jar in the 
  Bundle-Classpath section. The Import-Package section contains 
  javax.jms
- If I export this bundle to my project, and run validate I get 
  errors saying javax.jms cannot be found.
- If I omit the javax.jms from the bundles Import-Package there
  are no validation errors but I will get a ClassNotFoundException

我有点感觉这可能是嵌入式jar和Bundle-ClassPaths的问题...

我的捆绑包有

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: my.name
Bundle-SymbolicName: my.name
Bundle-Version: 1.0.0
Bundle-ClassPath: foo.jar
Export-Package: list_of_my_packages
Bundle-RequiredExecutionEnvironment: JavaSE-1.8

foo.jar有

Manifest-Version: 1.0
Bnd-LastModified: 1489769501680
Bundle-ManifestVersion: 2
Bundle-Name: foo
Bundle-SymbolicName: foo
Bundle-Version: 1.0.0
Class-Path: foo.libs.jar
Created-By: 1.8.0_71 (Oracle Corporation)
Export-Package: javax.jms  (and other stuff, omitted)
Import-Package: javax.jms;resolution:=optional (and other stuff, omitted)
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Tool: Bnd-2.4.0.201411031536

还有foo.libs.jar

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Foo libs
Bundle-SymbolicName: foo.libs
Bundle-Version: 1.1.0
Bundle-ClassPath: activemq-all.jar, (and others which I ommitted)
Export-Package: javax.jms, (and others which I ommitted)
Bundle-RequiredExecutionEnvironment: JavaSE-1.8

这个问题缺少细节,但是“找不到类”的问题在OSGI中是很典型的。

检查两个包的MANIFEST.MF。 foo.libs.jar必须在'Export-Package'指令中为您的“ missing”类声明一个程序包,而foo.jar在'Import-Package'中必须具有相同程序包。 由于您设法到达了发生异常的地步,因此好像您在foo.jar的“导入包”中缺少了some.class.in.a.jar.in.foo.libs.jar的包声明。

主要规则如下:捆绑包只能访问其自身内的类+通过清单导入的那些类。 虽然有捆绑片段和嵌入式依赖项等例外情况,但我相信在这种情况下我们可以忽略它们。

通常,只要在捆绑包的清单中同时设置“导入-”和“导出-包装”指令,就可以解决问题。 如果需要更详细的帮助,请提供有关如何制作foo.jar和foo.lib.jar的更多详细信息(手动,maven插件,gradle,使用的设置等)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM