Thursday, July 16, 2009

Flex compiler displays misleading headless-server errors

An error occurred because there is no graphics environment available. Please set the headless-server setting in the Flex configuration file to true.

The above error message might show up on your logs after calling Flex compiler (probably via Ant). This is sometimes done on a server that is not connected to a monitor or keyboard, A common scenario when using a build machine for build tasks. The first thing you should do is exactly what the error message implies, go to the flex-config.xml at the root of your project and change the following:


We got this error on our lab build machine at work, in our case and according to the web, in many other cases the property was already set to true, so the error message was useless. It was also very strange since this was not happening on a new server but on a build machine that was running Flex builds for months.

So what is happening here? The problem here is that the Flex compiler is using the java.awt.headless system property, a property other components seem to also be using. I assume that at first phase the compiler reads the flex-config.xml and sets java.awt.headless to true. It seems like this environment variable is getting later set to false by a different application\component along the way. Eventually the compiler gets to a line in it's code that requires the flag to be true and complains about the flag being set to false.

The workaround we used at work was to set this environment variable in the VM arguments:


This issue was researched and solved by Hila, one of my team members here in Wind River.


Cyb said...

Thank you, it's saved my time (-:

Shenuhan said...

Many many thanks !!!