java.lang.NoClassDefFoundError on OSGi

孤者浪人 提交于 2019-12-10 13:19:10

问题


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?


回答1:


Make sure you import the javax.swing package into your bundle:

Import-Package: javax.swing



回答2:


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




回答3:


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?




回答4:


Have you declared the Bundle-ClassPath in your bundle's MANIFEST.MF



来源:https://stackoverflow.com/questions/5181211/java-lang-noclassdeffounderror-on-osgi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!