Home » Eclipse Projects » Virgo » No frame contents in Swing app on Virgo
No frame contents in Swing app on Virgo [message #664513] |
Sun, 10 April 2011 16:26 |
Barbara Rosi-Schwartz Messages: 448 Registered: July 2009 |
Senior Member |
|
|
Hello everyone.
I am deploying a very simple Swing application to Virgo which instantiates a JFrame containing a JToolBar and a JLabel.
The JFrame appears without problems, but it has no contents. The same code works works fine if run standalone via the main() method.
I am attaching the source code for the bundle. Any idea as to what is wrong?
TIA,
Barbara
[Updated on: Sun, 10 April 2011 16:26] Report message to a moderator
|
|
| | | | | | | | | | | |
Re: No frame contents in Swing app on Virgo [message #664806 is a reply to message #664799] |
Tue, 12 April 2011 07:25 |
|
Glyn Normington wrote on Tue, 12 April 2011 07:23 | Did you try it on a 3.0 milestone BTW?
|
Yes I did last night on OS X and surprisingly it does work somewhat differently. Recall that on OS X I get the failure on the Aqua look-and-feel with 2.1.0, but on 3.0M3 there is no exception but the window still does not appear. Barbara started to look at on my machine but it too late so we quit and will pick it up this morning. We will set up 3.0 on her Win7 machine to isolate our efforts from OS X vagaries.
|
|
| | |
Re: No frame contents in Swing app on Virgo [message #664819 is a reply to message #664809] |
Tue, 12 April 2011 08:00 |
Glyn Normington Messages: 1222 Registered: July 2009 |
Senior Member |
|
|
Problem solved! Read on...
Next thing I noticed was some error handling in java.awt.EventDispatchThread:
/* Load the class, instantiate it, and find its handle method */
Method m;
Object h;
try {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
Class c = Class.forName(handlerClassName, true, cl);
m = c.getMethod("handle", new Class[] { Throwable.class });
h = c.newInstance();
} catch (Throwable x) {
handlerClassName = NO_HANDLER; /* Do not try this again */
return false;
}
Stepping in to the forName call, the class name was "apple.awt.CToolkit$EventQueueExceptionHandler" and the class loader was the application's bundle class loader. So the JDK is making a hierarchical class loader assumption that the bundle class loader will be able to load this class. This is the kind of thing I was talking about when I mentioned a bug in Swing, except this time it's a bug in AWT. However, there is a workaround as this situation is not entirely uncommon.
I added apple.* and, on a hunch, com.apple.* to the org.osgi.framework.bootdelegation property in lib/java6-server.profile and then the application behaved like it did under Equinox. ("Look mum!" was visible, for example.)
I presume Equinox's default boot delegation settings differ from those configured in Virgo.
|
|
| | |
Re: No frame contents in Swing app on Virgo [message #664823 is a reply to message #664821] |
Tue, 12 April 2011 08:22 |
Barbara Rosi-Schwartz Messages: 448 Registered: July 2009 |
Senior Member |
|
|
Ok, the first exception I am getting is a ClassNotDefFoundException from the ClasspathManager (line 495), when it is trying to look for class with classname "javax.swing.plaf.basic.BasicPanelUI" (stacktrace below)
What does that tell you?
[org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClassImpl(ClasspathManager.java:495),
org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass_LockClassLoader(ClasspathManager.java:469),
org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:449),
org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:216),
org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:393),
org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:469),
org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422),
org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410),
org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107),
org.eclipse.virgo.kernel.userregion.internal.equinox.KernelBundleClassLoader.loadClass(KernelBundleClassLoader.java:135),
java.lang.ClassLoader.loadClass(ClassLoader.java:248),
java.lang.Class.forName0(Native Method), java.lang.Class.forName(Class.java:247),
javax.swing.SwingUtilities.loadSystemClass(SwingUtilities.java:1850),
javax.swing.UIDefaults.getUIClass(UIDefaults.java:666),
javax.swing.UIDefaults.getUI(UIDefaults.java:738),
javax.swing.UIManager.getUI(UIManager.java:989),
javax.swing.JPanel.updateUI(JPanel.java:109),
javax.swing.JPanel.<init>(JPanel.java:69),
javax.swing.JPanel.<init>(JPanel.java:92),
javax.swing.JPanel.<init>(JPanel.java:100),
javax.swing.JRootPane.createGlassPane(JRootPane.java:528),
javax.swing.JRootPane.<init>(JRootPane.java:348),
javax.swing.JFrame.createRootPane(JFrame.java:255),
javax.swing.JFrame.frameInit(JFrame.java:236),
javax.swing.JFrame.<init>(JFrame.java:203),
org.foo.prova.Activator.init(Activator.java:42),
org.foo.prova.Activator.access$0(Activator.java:41),
org.foo.prova.Activator$1.run(Activator.java:36),
java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209),
java.awt.EventQueue.dispatchEventImpl(EventQueue.java:642),
java.awt.EventQueue.access$000(EventQueue.java:85),
java.awt.EventQueue$1.run(EventQueue.java:603),
java.awt.EventQueue$1.run(EventQueue.java:601),
java.security.AccessController.doPrivileged(Native Method),
java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87),
java.awt.EventQueue.dispatchEvent(EventQueue.java:612),
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269),
java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184),
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174),
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169),
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161),
java.awt.EventDispatchThread.run(EventDispatchThread.java:122)]
[Updated on: Tue, 12 April 2011 08:29] Report message to a moderator
|
|
|
Re: No frame contents in Swing app on Virgo [message #664826 is a reply to message #664819] |
Tue, 12 April 2011 08:28 |
|
Glyn Normington wrote on Tue, 12 April 2011 09:00 | Problem solved! Read on...
|
Neat!!!!
But, I have just done the same here using 2.1.0 and while I do get rid of the AquaLookAndFeel exception I do not get a Swing app visualising. Are you using 3M3? Let me know and I will try that.
But, just the fact that you can get the prova, with text, buttons and all is great. That is what is missing on Win7, so it appears that we might not be fighting windmill after all. Just need to find the right combo of assets that work, Then maybe we can work backwards to find out where and why the others fail.
Cheers,
Joel
|
|
| | |
Re: No frame contents in Swing app on Virgo [message #664840 is a reply to message #664835] |
Tue, 12 April 2011 09:16 |
|
Glyn Normington wrote on Tue, 12 April 2011 10:03 | The class loading behaviour hasn't changed much, if at all, between 2.1 and 3.0M3. Did you configure the boot delegation property the same in both cases?
We upgraded Equinox for 3.0, so that may be something to do with the difference.
|
Guess what? Put 3.0M3 on Win7 and prova still would not work. Looking at java6-server.profile I decided to take a shot and put javax.* into org.osgi.framework.bootdelegation property. And guess what, it all started to work fine
NOW I KNOW that I do not fully understand the ramifications of brute force putting javax.* into the boot delegator, so I need guidance in what can and should not be done here.
Btw, Barbara has now got the paint demo working on 3.0M3 in its full glory. We are almost there now, just have to set up a second repo host in M3 to get the last piece of the her infrastructure into place.
Joel
|
|
|
Re: No frame contents in Swing app on Virgo [message #664852 is a reply to message #664840] |
Tue, 12 April 2011 09:35 |
Glyn Normington Messages: 1222 Registered: July 2009 |
Senior Member |
|
|
Start by reading the OSGi R4.2 Core specification (available from www.osgi.org), section 3.8.3 Parent Delegation.
Essentially for packages available from the application class loader (AKA the "system" class loader) such as those included in the JRE, you either have to import them in your application and ensure they are exported from the system bundle by changing the org.osgi.framework.system.packages property in java6-server.profile or boot delegate them and not import them into your application.
The downside of boot delegating is that your application then has an implicit dependency on the environment (specifically on the boot delegation property) and so it will not fail to resolve if the relevant packages are unavailable.
Therefore adding javax.* to boot delegation is probably overkill. If some other application running on the server wanted to import a javax package from a bundle, then the classes of the javax package wouldn't be loaded from the bundle but from the application class loader instead.
If you can be more specific with the boot delegation property, e.g. javax.swing.*, that would be safer.
[Updated on: Tue, 12 April 2011 09:37] Report message to a moderator
|
|
| |
Goto Forum:
Current Time: Wed Sep 25 09:50:02 GMT 2024
Powered by FUDForum. Page generated in 0.05187 seconds
|