On Thu, 20 Jun 2013, Thomas Koch wrote:

Hi,
I just came across a strange issue on my Macbook where I built PyLucene3.6.2 a 
while ago and am using it since then (i.e. today) without any problems:

as of today I always get an error message

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

when I call lucene.initVM() or jcc.initVM()

If you don't need AWT, try passing vmargs=['-Djava.awt.headless=true'] to initVM(), like jcc itself does (see jcc's cpp.py vmargs initial value):

  lucene.initVM(vmargs=['-Djava.awt.headless=true'])

Andi..


I found several pages mentioning the error message but no hint how to resolve- 
except of this one:

The "Apple AWT Java VM was
loaded on first thread -- can't start AWT." message appears to be a red herring.
What is relevant is apparently not the thread on which the VM was created (via
JNI_CreateJavaVM), but rather the thread on which any Java AWT/Swing
functionality is actually triggered.  This interpretation would be in line with
what <http://developer.apple.com/library/mac/#technotes/tn2005/tn2147.html> "JNI
Development on Mac OS X - Thread-Safe JNI Programming - Calling AWT/Swing From
AppKit" says---the AppKit thread (i.e., the OOo main thread) must call AWT/Swing
only asynchronously (e.g., via javax.swing.SwingUtilities.inovkeLater).
(from https://issues.apache.org/ooo/show_bug.cgi?id=92926) could help, but I 
don't get where PyLucene is using anything related to AWT/Swing.

Has anyone encountered this issue and can provide a solution or workaround? Thx.

I thought it's related to some java updates ? but could also be some system 
settings. My env is

Darwin  12.4.0 Darwin Kernel Version 12.4.0
Python 2.7.2 (default, Oct 11 2012, 20:14:37)
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin

/usr/bin/java -version
java version "1.6.0_51"
Java(TM) SE Runtime Environment (build 1.6.0_51-b11-456-11M4508)
Java HotSpot(TM) 64-Bit Server VM (build 20.51-b01-456, mixed mode)
pylucene-3.6.2-1



regards
Thomas
--
full error message

2013-06-20 13:43:27.151 Python[89821:1207] 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:1827)
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1724)
        at java.lang.Runtime.loadLibrary0(Runtime.java:823)
        at java.lang.System.loadLibrary(System.java:1045)
        at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:50)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.awt.Toolkit.loadLibraries(Toolkit.java:1605)
        at java.awt.Toolkit.<clinit>(Toolkit.java:1627)
        at sun.awt.AppContext$2.run(AppContext.java:237)
        at sun.awt.AppContext$2.run(AppContext.java:226)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.awt.AppContext.initMainAppContext(AppContext.java:226)
        at sun.awt.AppContext.access$200(AppContext.java:112)
        at sun.awt.AppContext$3.run(AppContext.java:299)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.awt.AppContext.getAppContext(AppContext.java:280)
        at com.sun.jmx.trace.Trace.out(Trace.java:180)
        at com.sun.jmx.trace.Trace.isSelected(Trace.java:88)
        at 
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.isTraceOn(DefaultMBeanServerInterceptor.java:1830)
        at 
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:929)
        at 
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:916)
        at 
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:312)
        at 
com.sun.jmx.mbeanserver.JmxMBeanServer$2.run(JmxMBeanServer.java:1195)
        at java.security.AccessController.doPrivileged(Native Method)
        at 
com.sun.jmx.mbeanserver.JmxMBeanServer.initialize(JmxMBeanServer.java:1193)
        at 
com.sun.jmx.mbeanserver.JmxMBeanServer.<init>(JmxMBeanServer.java:225)
        at 
com.sun.jmx.mbeanserver.JmxMBeanServer.<init>(JmxMBeanServer.java:170)
        at 
com.sun.jmx.mbeanserver.JmxMBeanServer.newMBeanServer(JmxMBeanServer.java:1401)
        at 
javax.management.MBeanServerBuilder.newMBeanServer(MBeanServerBuilder.java:93)
        at 
javax.management.MBeanServerFactory.newMBeanServer(MBeanServerFactory.java:311)
        at 
javax.management.MBeanServerFactory.createMBeanServer(MBeanServerFactory.java:214)
        at 
javax.management.MBeanServerFactory.createMBeanServer(MBeanServerFactory.java:175)
        at 
sun.management.ManagementFactory.createPlatformMBeanServer(ManagementFactory.java:302)
        at 
java.lang.management.ManagementFactory.getPlatformMBeanServer(ManagementFactory.java:504)
        at 
org.apache.lucene.util.RamUsageEstimator.<clinit>(RamUsageEstimator.java:225)
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
lucene.JavaError



Reply via email to