eclipse OSGi 上的 java.lang.NoClassDefFoundError
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5181211/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
java.lang.NoClassDefFoundError on OSGi
提问by John John Pichler
I have a bundle, with an activator declared. This activator create a JFrame and show it.
我有一个包,声明了一个激活器。这个激活器创建一个 JFrame 并显示它。
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
在 Eclipse 上作为插件项目运行它工作正常。当我穿上 Felix 时,它不再起作用了。它显示: 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.
但是 MainFrame 位于激活器所在的同一个包中,当然,作为一个公共类。我不明白为什么类加载器找不到类。
Anyone knows what is happening?
有谁知道发生了什么?
采纳答案by Neil Bartlett
Make sure you import the javax.swing
package into your bundle:
确保将javax.swing
包导入到包中:
Import-Package: javax.swing
回答by Distortum
Use this VM argument:
使用此 VM 参数:
-Djava.specification.version=1.6
-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
这将强制 Felix 提供 Java 6 的默认系统包集,其中包括javax.swing
及其子包
回答by John John Pichler
Now it works! I configured boot delegation in config file!
现在它起作用了!我在配置文件中配置了引导委托!
I put org.osgi.framework.bootdelegation=in config.ini.
我把org.osgi.framework.bootdelegation=放在 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.
你们两个应该先告诉我这个,嘿嘿。现在我在 equinox wiki 中读到,遵循 OSGi 规范,我需要定义我需要使用的每个包,我认为这是正确的,因为一些定制的 VM 可以比其他的有更多的库。
But Eclipse don't works in this concept of importing every java package (like javax.swing). I'll report this in Eclipse Bugzilla.
但是 Eclipse 不适用于导入每个 java 包(如 javax.swing)的概念。我将在 Eclipse Bugzilla 中报告这个问题。
Many thanks both you!
非常感谢你们!
PS: What are your book @Neil?
PS:你的书是什么@Neil?
回答by Suraj Chandran
Have you declared the Bundle-ClassPath in your bundle's MANIFEST.MF
你是否在你的包的 MANIFEST.MF 中声明了 Bundle-ClassPath