简体   繁体   English

OSGi中的传递依赖

[英]Transitive dependencies in OSGi

I'm getting a NoClassDefFoundError at runtime and I thought the "uses" directive would avoid this because I thought it created transitivity (correct me if I'm wrong). 我在运行时得到一个NoClassDefFoundError ,我认为"uses"指令会避免这种情况,因为我认为它创造了传递性(如果我错了,请纠正我)。 Here is my configuration: 这是我的配置:

Bundle 1 
  Export-package A

Bundle 2 
  Export-package B, uses "A"
  Import-package A

Bundle 3
  Import-package B

Now, the exception happens when Bundle 3 makes a call to a class in B which in turn makes a call to a class in A . 现在,当Bundle 3调用B中的一个类时会发生异常,而B又调用A中的类。 Based on the console, i can see that the BundleClassLoader looks for the class in bundle 3 (in other words, in itself), but not in Bundle 1 where it would find it. 基于控制台,我可以看到BundleClassLoader在bundle 3中查找类(换句话说,就其本身而言),但在Bundle 1中找不到它。 If i force BND to import A in Bundle 3 everything works fine, but it looks too labor intensive. 如果我强制BND导入捆绑3中的A一切正常,但它看起来太费力了。 i feel like I'm missing something. 我觉得我错过了什么。 Shouldn't equinox use the info in the manifests to set the bundle classpath? equinox不应该使用清单中的信息来设置bundle classpath吗? or in the worst case, shouldn't BND detect the dependency of 3 on 1 and import package A in the manifest of 3? 或者在最坏的情况下,BND不应该检测3对1的依赖关系并在3的清单中导入包A?

All my bundles are active and i have no uses constraint violations 我的所有捆绑包都是active ,我没有uses约束违规

Bundle 2 must also import A. The uses A says that any bundle that imports my B and also imports A must import the same A as me. 捆绑2也必须导入A.使用A表示任何导入我的B并且还导入A的捆绑包必须导入与我相同的A. Since bundle 2 does not import A, this doesn't work. 由于bundle 2不导入A,因此不起作用。 Also, bundle 3 needs to import A since B uses A. Any importer of B is also a user of A and so must import A. 此外,捆绑3需要导入A,因为B使用A.任何B的导入者也是A的用户,因此必须导入A.

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

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