No classDefFoundError Apache Karaf

huangapple go评论73阅读模式
英文:

No classDeffoundError Apache Karaf

问题

我在项目中使用 hapi-osgi-base v2.2 bundle,并在 karaf 容器中安装相同的 bundle,以便在运行时在我的代码中使用它。karaf 容器已预安装了 hapi-osgi-base v1.2 bundle,我的代码尝试使用 v1.2 bundle,并抛出 NoClassDefFoundError。我尝试在导入包部分指定范围 [2.2, 3.0),但我的 bundle 无法解析该范围,因为 hapi-osgi-base 并未导出版本 2.2 的包。有趣的是,它只导出所有带有 v0.0.0 的包。我不确定这是否与他们的 pom 文件有关。

我尝试使用<Embed-Dependency>hapi-osgi-base;version="2.2";scope=runtime</Embed-Dependency>,但仍然出现 NoClassDefFoundError。请提供建议。

英文:

I am using the hapi-osgi-base v2.2 bundle in my project and installing the same in the karaf container for my code to use it in the runtime. The karaf container already has a hapi-osgi-base v 1.2 bundle pre-installed my code was trying to use v 1.2 bundle and throwing a NoClassDefFoundError. I tried to specify the range in the import package section [2.2, 3.0) in the bundle. My bundle cannot resolve, range because hapi-osgi-base was not exporting the package version 2.2. It is also interesting it is only exporting all packages with v 0.0.0. I am not sure if it is something to do with their pom.

I tried to use <Embed-Dependency>hapi-osgi-base;version="2.2";scope=runtime</Embed-Dependency>. I still get the No ClassDeffoundError. Please suggest.

答案1

得分: 1

以下是您要翻译的内容:

OSGI的经验法则是,如果出现“ClassNotFoundException”错误,则表示您未进行导出,而java.lang.NoClassDefFoundError错误则是未进行导入。

请参阅此链接:https://stackoverflow.com/questions/5181211/java-lang-noclassdeffounderror-on-osgi

英文:

Rule of thumb with OSGI is that if you get a "ClassNotFoundException", you're not exporting it, while java.lang.NoClassDefFoundError is when you don't Import it.

See this https://stackoverflow.com/questions/5181211/java-lang-noclassdeffounderror-on-osgi

huangapple
  • 本文由 发表于 2020年9月23日 00:01:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/64013506.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定