Java.lang.NoClassDefFoundError on OSGi

I have a package with a declared activator. This activator creates a JFrame and shows it.

Running in an Eclipse as Plugin project works fine. When I put on Felix, it no longer works. This shows: java.lang.NoClassDefFoundError: com / griep / ui / MainFrame

But MainFrame is in the same package as the activator, like an open class, of course. I do not understand why the class loader does not find the class.

Does anyone know what is going on?

+6
java eclipse osgi apache-felix helios
source share
4 answers

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

 Import-Package: javax.swing 
+6
source share

Use this VM argument:

-Djava.specification.version=1.6

This will force Felix to provide an affordable set of default system packages for Java 6, which includes javax.swing and its subpackages.

+2
source share

Now it works! I have configured delegate loading in the configuration file!

I put org.osgi.framework.bootdelegation = in config.ini.

You both told me this before you guys hehe. Now I read in the wiki that, after the OSGi specification, I need to define every package that I need to use, and I think that it is correct, because some configured virtual machines may have more libs than others.

But Eclipse does not work in this import concept of every java package (e.g. javax.swing). I will report this in Eclipse Bugzilla.

Thanks a lot to both of you!

PS: What is your @Neil book?

+1
source share

You declared Bundle-ClassPath in your package MANIFEST.MF

0
source share

All Articles