[jbosstools-dev] Special profile for java 1.7 on mac - how to do it

Martin Malina mmalina at redhat.com
Fri Nov 16 07:48:13 EST 2012


On 16. 11. 2012, at 9:49, Max Rydahl Andersen <max.andersen at redhat.com> wrote:

>>> We've been having a problem with running our bot tests on OS X with java 1.7. This is what we get:
>>> java.awt.AWTException: headless environment
>>> To overcome this, we need to add this property to the tycho surefire argLine: -Dawt.toolkit=sun.lwawt.macosx.LWCToolki
>> I hate Mac, they are the worst thing that happened to Java developers, I still don't understand why so many Java developers use them... That said ;)
> 
> Yes, Oracle fucked it up, and Maven fucks it up even worse in this case...i.e. why on *earth* would anyone have profile enablement be based on an "or".
> 
>> Is this property set by default on Mac when using Eclipse? Are there some success stories of Eclipse on OSX with Java 1.7 ?
>> It could be an upstream issue.
>> 
> 
> yeah - I'm curious about this - where did you find out sun.lwawt.macosx.LWCToolkit would solve it ? is this swtbot being weird ?

SWT bot is using awt under the hood for something - simulating keyboard pressing I think. Lucia found out about the fix so I don't know how. And she's on maternity leave, so she won't tell us :)

> 
> note I google this and found we apparently have code that messes with this in our tests ?!
> 
> http://lists.jboss.org/pipermail/jbosstools-commits/2012-September/041589.html
> 
> so this is not a new issue?

Yes, it is not a new issue. But I didn't know about the hack in bot ext that is supposed to deal with this. And our dummy test where I was debugging this doesn't use bot ext (Jirka just submitted a pull request changing this test to use ReqAwareSuite from bot ext so that should fix it).

> 
> What is the full stacktrace of that error about "headless environment" ?

Strangely enough when I tried this on my own MacBook the property was set correctly and the test ran fine. 
For AppleJDK the property is: awt.toolkit=apple.awt.CToolkit
For OracleJDK it is: awt.toolkit=sun.lwawt.macosx.LWCToolkit
So there must be something wrong with the jenkins slaves that they set the property incorrectly for OracleJDK1.7 on Mac.

But anyway, it seems for now we will try to solve this with the hack in bot ext (or fixing the slaves if we can determine how it happens).
The exception when this happens is this:
Error Message

java.awt.AWTException: headless environment
Stacktrace

java.lang.RuntimeException: java.awt.AWTException: headless environment
	at org.eclipse.swtbot.swt.finder.keyboard.AWTKeyboardStrategy.<init>(AWTKeyboardStrategy.java:39)
	at org.eclipse.swtbot.swt.finder.keyboard.KeyboardFactory.getAWTKeyboard(KeyboardFactory.java:103)
	at org.eclipse.swtbot.swt.finder.keyboard.KeyboardFactory.getDefaultKeyboard(KeyboardFactory.java:80)
	at org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBot.keyboard(AbstractSWTBot.java:837)
	at org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBot.pressShortcut(AbstractSWTBot.java:853)
	at org.jboss.tools.dummy.ui.bot.test.DummyTest.dummyTest(DummyTest.java:38)
	at org.jboss.tools.dummy.ui.bot.test.DummyTest.hundredTimes(DummyTest.java:54)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
	at org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner.run(SWTBotJunit4ClassRunner.java:54)
	at org.junit.runners.Suite.runChild(Suite.java:128)
	at org.junit.runners.Suite.runChild(Suite.java:24)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
	at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:53)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:123)
	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:104)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164)
	at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)
	at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:175)
	at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(SurefireStarter.java:123)
	at org.eclipse.tycho.surefire.osgibooter.OsgiSurefireBooter.run(OsgiSurefireBooter.java:85)
	at org.eclipse.tycho.surefire.osgibooter.AbstractUITestApplication.runTests(AbstractUITestApplication.java:44)
	at org.eclipse.ui.internal.testing.WorkbenchTestable$1.run(WorkbenchTestable.java:71)
	at java.lang.Thread.run(Thread.java:722)
Caused by: java.awt.AWTException: headless environment
	at java.awt.Robot.<init>(Robot.java:94)
	at org.eclipse.swtbot.swt.finder.keyboard.AWTKeyboardStrategy.<init>(AWTKeyboardStrategy.java:37)
	... 49 more

Thanks,
Martin


More information about the jbosstools-dev mailing list