Try to set the Thread context classloader to be the classloader of your bundle before the call to UIManager.
regards, Karl On Wed, Oct 14, 2009 at 10:27 PM, Sangjin Lee <[email protected]> wrote: > I'm running into an interesting classloading problem with Felix > (2.0.0) on my mac. I have a simple test activator like the following: > > public class LAFClassLoadingTest implements BundleActivator { > public void start(BundleContext c) throws Exception { > // loads internal apple laf class via Class.forName() > UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); > } > > public void stop(BundleContext c) {} > } > > When I install and start this bundle, I get a NoClassDefFoundError > with apple/laf/CoreUIControl: > > org.osgi.framework.BundleException: Activator start error in bundle > lafclassloading_test [4]. > at org.apache.felix.framework.Felix.activateBundle(Felix.java:1750) > at org.apache.felix.framework.Felix.startBundle(Felix.java:1621) > at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:890) > at > org.apache.felix.shell.impl.StartCommandImpl.execute(StartCommandImpl.java:114) > at > org.apache.felix.shell.impl.Activator$ShellServiceImpl.executeCommand(Activator.java:281) > at > org.apache.felix.shell.tui.Activator$ShellTuiRunnable.run(Activator.java:184) > at java.lang.Thread.run(Thread.java:637) > Caused by: java.lang.NoClassDefFoundError: apple/laf/CoreUIControl > at com.apple.laf.AquaLookAndFeel$1.run(AquaLookAndFeel.java:123) > at java.security.AccessController.doPrivileged(Native Method) > at com.apple.laf.AquaLookAndFeel.initialize(AquaLookAndFeel.java:120) > at javax.swing.UIManager.setLookAndFeel(UIManager.java:545) > at javax.swing.UIManager.setLookAndFeel(UIManager.java:590) > at org.osgi.test.LAFClassLoadingTest.start(LAFClassLoadingTest.java:13) > at > org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:667) > at org.apache.felix.framework.Felix.activateBundle(Felix.java:1699) > ... 6 more > java.lang.NoClassDefFoundError: apple/laf/CoreUIControl > > I googled for this issue, and tried a couple of suggested solutions. > > First, I tried adding the apple.laf package to the > org.osgi.framework.system.packages.extra property, and also added it > to the Import-Package property of my bundle. It still failed with the > same error, although I could see that the dependency was successfully > resolved. > > Second, I tried the org.osgi.framework.bootdelegation property, and > added apple packages. Still no success, and I failed with the same > NoClassDefFoundError. > > Can anyone shed light on why this classloading is not working even > with these solutions, and what is the "right" way to make this work? > > FYI, the bundle starts just fine with Equinox. > > Thanks, > Sangjin > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > > -- Karl Pauls [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

