There apparently is a bug in Java native library loading that causes this:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4809647
If you are using the Felix shell TUI, you can try to set the following
system property when you launch the framework:
-Dshell.tui.checkinput=true
-> richard
On 4/12/10 8:13, [email protected] wrote:
Hi,
My use case is: I want to render an image on the server side. I'm using
the AWT-APIs for this.
My problem: I'm getting a deadlock when calling the method
"Toolkit.getDefaultToolkit()" in an OSGi environment (equinox or felix).
Here is a test case to reproduce the problem:
http://support.isr.de/download/isr/awt-osgi-problem.zip
Run the .cmd-file "run-with-felix.cmd". If you get the message "After 10
seconds, the AWT Toolkit still could not be initialized. This is a bug!"
you have reproduced the error.
The error only occurs an a windows system. On an ubuntu system (probably
on every unix based system) the test case produces no error.
I noticed some strange behavior while trying to solve the problem:
- pressing "enter" in the console from which I control the OSGi runtime
resolves the lock
- jvisualvm cannot create a thread dump while the deadlock exists
Has anyone an idea? Where is the error?
Thanks!
p.s.: To understand the error I stepped through the sourcecode and got
finally into the class "sun.awt.window.WToolkit". For a better
understanding of the problem have a look at the sourcecode of
"WToolkit.java" (see end of the message for a shortened version)
In the constructor of this class a new deamon thread is started. After
starting this thread "wait()" is called. The deamon thread should notify
the main thread after finishing. This deamon thread calls the native
method "init()" from the library "awt.dll" to do some initializing stuff.
This call does not return and so the thread never calls the method
notifyAll() to notify the main thread.
[..]
public class WToolkit extends SunToolkit implements Runnable {
[..]
public WToolkit() {
// Startup toolkit threads
if (PerformanceLogger.loggingEnabled()) {
PerformanceLogger.setTime("WToolkit construction");
}
sun.java2d.Disposer.addRecord(anchor, new ToolkitDisposer());
synchronized (this) {
// Fix for bug #4046430 -- Race condition
// where notifyAll can be called before
// the "AWT-Windows" thread's parent thread is
// waiting, resulting in a deadlock on startup.
/*
* Fix for 4701990.
* AWTAutoShutdown state must be changed before the toolkit
thread
* starts to avoid race condition.
*/
AWTAutoShutdown.notifyToolkitThreadBusy();
if (!startToolkitThread(this)) {
Thread toolkitThread = new Thread(this, "AWT-Windows");
toolkitThread.setDaemon(true);
toolkitThread.start();
}
try {
wait();
}
catch (InterruptedException x) {
}
}
SunToolkit.setDataTransfererClassName(DATA_TRANSFERER_CLASS_NAME);
// Enabled "live resizing" by default. It remains controlled
// by the native system though.
setDynamicLayout(true);
}
public void run() {
Thread.currentThread().setPriority(Thread.NORM_PRIORITY+1);
boolean startPump = init();
[..]
synchronized(this) {
notifyAll();
}
if (startPump) {
eventLoop(); // will Dispose Toolkit when shutdown hook
executes
}
}
[..]
Mit freundlichen Grüßen
Simon Eiersbrock
Software Engineer
ISR Information Products AG
Hafenweg 14
D-48155 Muenster
mailto:[email protected]
Tel: +49 (0)251-9 24 34-203
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]