Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

"AWT was loaded on first thread"



I am writing a C++ command line program (using CodeWarrior and the Mac OS X PowerPC Mach-O linker to create an executable) in which I want to invoke a Java VM.

The class I'm trying to use indirectly uses AWT. It executes as expected if I run it using "java -cp ...", but if I run it from my program I get the following error:

2005-03-20 22:47:18.355 mytest[1041] Apple AWT Java VM was loaded on first thread -- can't start AWT.
Exception in thread "main" java.lang.InternalError: Can't start the AWT because Java was started on the first thread. Make sure StartOnFirstThread is not specified in your application's Info.plist or on the command line
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1586)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1503)
at java.lang.Runtime.loadLibrary0(Runtime.java:788)
at java.lang.System.loadLibrary(System.java:834)
at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:50)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Toolkit.loadLibraries(Toolkit.java:1437)
at java.awt.Toolkit.<clinit>(Toolkit.java:1458)
at quicktime.QTSession.<clinit>(QTSession.java:77)
at squarebox.mytest.Main.main(Main.java:72)


I tried restructuring my code so it fires off a new thread instead of initialising the AWT Toolkit from my main thread. Sure enough, the error goes away, but instead the application just hangs, with the thread dump below. Again, the problem seems to lie in Toolkit.loadLibraries().

Any ideas?

-Rolf


Full thread dump Java HotSpot(TM) Client VM (1.4.2-38 mixed mode):

"Runner" prio=5 tid=0x0110b530 nid=0x282ac00 runnable [f0405000..f0407b20]
        at java.lang.ClassLoader$NativeLibrary.load(Native Method)
        at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1586)
        - locked <0x65000228> (a java.util.Vector)
        - locked <0x65000278> (a java.util.Vector)
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1503)
        at java.lang.Runtime.loadLibrary0(Runtime.java:788)
        - locked <0x65012160> (a java.lang.Runtime)
        at java.lang.System.loadLibrary(System.java:834)
        at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:50)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.awt.Toolkit.loadLibraries(Toolkit.java:1437)
        at java.awt.Toolkit.<clinit>(Toolkit.java:1458)
        at quicktime.QTSession.<clinit>(QTSession.java:77)
        at squarebox.mytest.Main._main(Main.java:97)
        at squarebox.mytest.Main.access$0(Main.java:58)
        at squarebox.mytest.Main$1.run(Main.java:52)

"Signal Dispatcher" daemon prio=10 tid=0x01107f30 nid=0x2812600 waiting on condition [0..0]

"Finalizer" daemon prio=8 tid=0x011069d0 nid=0x280d800 in Object.wait() [f0203000..f0203b20]
at java.lang.Object.wait(Native Method)
- waiting on <0x65000448> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:111)
- locked <0x65000448> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:127)
at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)


"Reference Handler" daemon prio=10 tid=0x011066a0 nid=0x2802200 in Object.wait() [f0182000..f0182b20]
at java.lang.Object.wait(Native Method)
- waiting on <0x65000338> (a java.lang.ref.Reference$Lock)
at java.lang.Object.wait(Object.java:429)
at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:115)
- locked <0x65000338> (a java.lang.ref.Reference$Lock)


"main" prio=5 tid=0x01100c50 nid=0xa000a1ec waiting on condition [bffff000..bffff938]
at java.lang.Thread.sleep(Native Method)
at squarebox.mytest.Main.main(Main.java:55)


"VM Thread" prio=5 tid=0x01105f20 nid=0x2802600 runnable

"VM Periodic Task Thread" prio=10 tid=0x01107e70 nid=0x2812200 waiting on condition
"Exception Catcher Thread" prio=10 tid=0x01100db0 nid=0x2801200 runnable
--
Rolf Howarth, Square Box Systems Ltd, Stratford-upon-Avon UK.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden


This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.