Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 328126 - SWT Webstart Applet - Second instance of same applet causes Invalid thread access
Summary: SWT Webstart Applet - Second instance of same applet causes Invalid thread ac...
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.1   Edit
Hardware: PC Windows 7
: P3 major with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-19 09:51 EDT by Jiri Sliva CLA
Modified: 2022-02-11 14:33 EST (History)
2 users (show)

See Also:


Attachments
Testing applet sources. (9.27 KB, application/x-zip-compressed)
2010-10-21 07:45 EDT, Jiri Sliva CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jiri Sliva CLA 2010-10-19 09:51:43 EDT
Build Identifier: I20090611-1540

Hello,

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 more instances of applet is started by webstart from browser then some that 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.

If browser will start unique JVM for each webstart applet depends on browser. Firefox uses all time only one JVM, Internet Explorer starts more instances of JVM (e.g. 2 JVMs for 5 applets).

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(SWT.java:3884)
	at org.eclipse.swt.SWT.error(SWT.java:3799)
	at org.eclipse.swt.SWT.error(SWT.java:3770)
	at org.eclipse.swt.widgets.Widget.error(Widget.java:463)
	at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:355)
	at org.eclipse.swt.widgets.Shell.getShell(Shell.java:1080)
	at org.eclipse.swt.widgets.Control.sendFocusEvent(Control.java:2568)
	at org.eclipse.swt.widgets.Widget.wmSetFocus(Widget.java:2282)
	at org.eclipse.swt.widgets.Control.WM_SETFOCUS(Control.java:4573)
	at org.eclipse.swt.widgets.Canvas.WM_SETFOCUS(Canvas.java:449)
	at org.eclipse.swt.widgets.Decorations.WM_SETFOCUS(Decorations.java:1728)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4014)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:342)
	at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1578)
	at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:2010)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4589)
	at org.eclipse.swt.internal.win32.OS.SetFocus(Native Method)
	at org.eclipse.swt.widgets.Control.forceFocus(Control.java:978)
	at org.eclipse.swt.widgets.Control.setFocus(Control.java:2965)
	at org.eclipse.swt.widgets.Composite.setFocus(Composite.java:928)
	at org.eclipse.swt.widgets.Shell.open(Shell.java:1220)
	at example.TestApplet.run(TestApplet.java:65)
	at java.lang.Thread.run(Unknown Source)


I can provide war archive with mentioned testing applet and JNLP files.
http://snadzitra.net/tmp/webstart/example-swt-webstart-applet.zip

We were asking in Eclipse Community Forum, but without response.
http://www.eclipse.org/forums/index.php?t=msg&th=197936&start=0&S=a8a75afdb90d8a39fc8160e67381ea9c

Thanks in advance.

Kind regards,
-Jiri Sliva


Reproducible: Always

Steps to Reproduce:
1. Download and build (or use prepared war) following testing applet  http://snadzitra.net/tmp/webstart/example-swt-webstart-applet.zip
2. Deploy it to some webserver (we tested it on apache-tomcat-6.0.26.
3. Start two instances of applet. 
4. In Java Console you should see mentioned exception.
Comment 1 Jiri Sliva CLA 2010-10-21 07:45:44 EDT
Created attachment 181382 [details]
Testing applet sources.

Two maven based project.
 - example-webstart-applet contains TestApplet class and produces example-webstart-applet-0.0.1.jar which will be included into war.
 - example-webstart-web is packaging war project.

Build:

go to folder example-webstart-applet
$ mvn install

go to folder example-webstart-web
$ mvn install
Comment 2 Eclipse Webmaster CLA 2019-09-06 16:07:15 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.
Comment 3 Alexander Kurtakov CLA 2022-02-11 14:33:04 EST
Applet is dead technology and no longer in recent JVMs nor browsers support it.