Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » SWT Applet, webstart and Invalid thread access
SWT Applet, webstart and Invalid thread access [message #631129] Wed, 06 October 2010 09:48
Jiri Sliva is currently offline Jiri SlivaFriend
Messages: 3
Registered: October 2010
Junior Member

We have SWT-based applet (uses SWT_AWT bridge) which we want to starts via webstart.
Problems occurs when we try start second instance of that applet (in same browser).

In last step of applet's UI initialization - on first call of display.readAndDispatch() is raised Invalid thread access exception.

Line 2 on following code ..
1.    while (!shell.isDisposed()) {
2.      if (!display.readAndDispatch()) {
3.        display.sleep();
4.      }
5.    }
6.    display.dispose();

Some facts:
- Each applet instance has own shell and display and runs in own threads.
- Same behavior in Mozilla Firefox and MS IE.
- Exception isn't raised when applet is started WITHOUT Webstart/JNLP (but in classic approach).
- Exception isn't raised when applet is started directly by javaws executable. I mean without browser java plugin (e.g. opening jnlp file from windows explorer). In that case have each applet own JVM.
- Usage of pack200 doesn't have any impact to this issue.

When applet is started by webstart from browser then all applets are running in same JVM but in different "sandboxes" (different classloaders?) - so it looks that applets are separated but there still remains some sharing in SWT internals.

Exception details:

Java Plug-in 1.6.0_21
Using JRE version 1.6.0_21-b07 Java HotSpot(TM) Client VM
Wed Oct 06 11:37:10 CEST 2010: TestApplet - Started
Wed Oct 06 11:37:10 CEST 2010: TestApplet - Initialized. Start UI Loop.
Exception in thread "UI" org.eclipse.swt.SWTException: Invalid thread access
	at org.eclipse.swt.SWT.error(
	at org.eclipse.swt.SWT.error(
	at org.eclipse.swt.SWT.error(
	at org.eclipse.swt.widgets.Widget.error(
	at org.eclipse.swt.widgets.Widget.checkWidget(
	at org.eclipse.swt.widgets.Shell.getShell(
	at org.eclipse.swt.widgets.Control.sendFocusEvent(
	at org.eclipse.swt.widgets.Widget.wmSetFocus(
	at org.eclipse.swt.widgets.Control.WM_SETFOCUS(
	at org.eclipse.swt.widgets.Canvas.WM_SETFOCUS(
	at org.eclipse.swt.widgets.Decorations.WM_SETFOCUS(
	at org.eclipse.swt.widgets.Control.windowProc(
	at org.eclipse.swt.widgets.Canvas.windowProc(
	at org.eclipse.swt.widgets.Decorations.windowProc(
	at org.eclipse.swt.widgets.Shell.windowProc(
	at org.eclipse.swt.widgets.Display.windowProc(
	at org.eclipse.swt.internal.win32.OS.SetFocus(Native Method)
	at org.eclipse.swt.widgets.Control.forceFocus(
	at org.eclipse.swt.widgets.Control.setFocus(
	at org.eclipse.swt.widgets.Composite.setFocus(
	at Source)

I can provide war archive with mentioned testing applet and JNLP files.
Thank in advance for any idea ..

Best regards
Previous Topic:SWT Threads
Next Topic:Re: Data getting truncated in a TableViewer
Goto Forum:

Current Time: Sat Dec 14 09:54:38 GMT 2019

Powered by FUDForum. Page generated in 0.02026 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top