OSGi 上的 java.lang.NoClassDefFoundError
我有一个捆绑包,声明了一个激活器。该激活器创建一个 JFrame 并显示它。
在 Eclipse 上作为插件项目运行它工作正常。当我戴上菲利克斯后,它就不再起作用了。 它显示: java.lang.NoClassDefFoundError: com/griep/ui/MainFrame
但是 MainFrame 与激活器位于同一个包中,当然,作为一个公共类。我不明白为什么类加载器不是'找不到班级。
有人知道发生了什么事吗?
I have a bundle, with an activator declared. This activator create a JFrame and show it.
Running on Eclipse as Plugin project it works fine. When I put on Felix it doesn't work anymore.
It shows:
java.lang.NoClassDefFoundError: com/griep/ui/MainFrame
But MainFrame is located in the same bundle the activator is, as a public class, of course. I don't understand why the classloader isn't finding the class.
Anyone knows what is happening?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
确保将
javax.swing
包导入到您的包中:Make sure you import the
javax.swing
package into your bundle:使用此 VM 参数:
-Djava.specation.version=1.6
这将强制 Felix 提供 Java 6 的默认系统包集,其中包括
javax.swing
和它的子包Use this VM argument:
-Djava.specification.version=1.6
This will force Felix to make available the default set of system packages for Java 6, which includes
javax.swing
and its sub-packages现在可以了!我在配置文件中配置了启动委派!
我将 org.osgi.framework.bootdelegation= 放入 config.ini 中。
你们俩应该先告诉我这一点,嘿嘿。现在我在 equinox wiki 中读到,遵循 OSGi 规范,我需要定义我需要使用的每个包,我认为这是正确的,因为一些定制的虚拟机可以比其他虚拟机拥有更多的库。
但 Eclipse 并不支持导入每个 java 包(如 javax.swing)的概念。我将在 Eclipse Bugzilla 中报告这一点。
非常感谢你们!
PS:@Neil 你的书是什么?
Now it works! I configured boot delegation in config file!
I put org.osgi.framework.bootdelegation= in config.ini.
Both of you should told me this before guys hehe. Now I read in equinox wiki, that following the OSGi specification I need to define every package I need to use, and I think its right, because some customized VMs can have more libs than other.
But Eclipse don't works in this concept of importing every java package (like javax.swing). I'll report this in Eclipse Bugzilla.
Many thanks both you!
PS: What are your book @Neil?
您是否在捆绑包的 MANIFEST.MF 中声明了 Bundle-ClassPath
Have you declared the Bundle-ClassPath in your bundle's MANIFEST.MF