Sunday, November 22, 2009

Setting SDK 3.4.1 on Flash Builder

So Flex is now Flash Builder (4), like many other developers I was excited to try out the new Adobe IDE. I was especially interested in the much needed bug fixes from Flex 3 and missing features (at last a proper 'Generate getters and setters' option for AS classes). As a Linux user I was also very disappointed to find out that Adobe has currently neglected it's Builder for Linux support. Now, flash Builder's default SDK version is 4, you'll notice that on the first time that you'll start a Flex project on FB4. Version 4 introduces new AS libraries and a new MXML syntax, but most of us only want to test run FB4 using the same code and syntax we used with the 3.x.x SDK versions. Luckily the new builder has an optional 3.4.1 SDK you can use for your projects. Here's how you can set SDK 3.4.1 as your default SDK with FB4:

1. On Eclipse top menu select Window > Preferences and the Preferences window will popup
2. On the left tree select Flash Builder > Installed Flex SDK's
3. Check SDK 3.4 and press Apply



From now on all your Flash Builder new projects will be using the 3.4.1 SDK

Saturday, October 10, 2009

Bugzilla on Ubuntu 8.04 - Installation problem


Bugzilla seems to be one of these products people are stying loyal to no matter what. I honestly love the simplicity of the tool, I've used many other bug tracking systems but Bugzilla will always remain my#1 favorite. I've recently decided to install Bugzilla on my Ubuntu 8.04 machine. I was happy to find out that this can be done using apt-get, as Bugzilla installations always seem to be bugy. Used the following line for the installation:
sudo apt-get install bugzilla
That seemed to have worked I thought, but when I was done I tried to browse to the new Bugzilla site and got an Internal Server Error message.

In order to fix the problem and get your Bugzilla up and running here's what you need to do: access your mysql admin using both command line or MySQL Adminstrator app , Assign all privileges to the user debian-sys-maint @ localhost on the bugzilla Schema.



Once you are done go back to your local to the bugzilla web page on your localhost, you should now be able to see the Bugzilla web interface. This solution and some explanations may be found on this thread.

Wednesday, September 30, 2009

Flex 3 on build machine: Flex Charting Components water mark


I was dealing with the following problem: when compiling my Flex app locally using both FB3 or Ant, Flex Charting Components appeared just as you expect them to, they did not display the annoying water mark that non licensed users may get. But when the application was compiled using my team's build machine it produced the annoying watermark on top of all the application charts. So what went wrong? Raghu has the answer, to make a long story short, all I had to do is to update the flex-config.xml with my license number:

<licenses>
<license>
<product>flexbuilder3</product>
<serial-number>your serial number here</serial-number>
</license>
</licenses>


Raghu's detailed explanation and some info about the licensing mechanism on Flex 3

Licensing configuration on Adobe's live docs

Sunday, September 27, 2009

Drupal - Setting any page as front page


Drupal is a great CMS that seems to be gaining more and more popularity over time and for a good reason, overall I belive it's the best CMS available today, There might be a number of products out there with better architecture and design but none of them has a huge community of users behind them like Drupal. On the other hand, I do feel that Drupal lacks documentation. In some cases it seems to take ages to find how to apply simple configurations in Drupal's admin screens. For instance, I spent some time today trying to understand how to perform a simple task, making a page on your site the default site front page, here's how it's done with Drupal 6.x:

1. Go to the Admin panel

2. Select Site Information

3. scroll down to the Default front page field and insert the name of the page you would like to set as front page

4. Press Save Configuration




Saturday, August 15, 2009

Jython - Convert File to Byte Array


I've recently started developing with Jython and I love the language. the combination of Python's dynamic features with Java is extremely powerful. If you are not familiar with Python or Jython, be sure to check the above links. As an Action Script veteran, I have to admit that Python makes me miss the early days of AS, when the language was dynamic and weakly typed.

The following is an example of a typical web client task, a conversion of a local file to a Byte array, such a conversion is common when sending a local file from the client to a Java server, using SOAP Web Services or other integration layer. Here is an example of a file to Byte array conversion in Jython, it's a Jython version of a simple java code I've found here:

from java.lang import Byte
from java.io import FileInputStream
from java.io import File
import jarray

def getByteArray(self,fileUrl):
file = File(fileUrl);
inputStream = FileInputStream(file)
length = file.length()
bytes = jarray.zeros(length, 'b')
#Read in the bytes
offset = 0
numRead = 0
while offset<length:
if numRead>= 0:
print numRead
numRead=inputStream.read(bytes, offset, length-offset)
offset = offset + numRead
return bytes

As you can see, I had to use the jarray Jython module in this code. Jarray provides a much needed API that is missing from Jython's core modules. It exposes two methods which allow you to construct Typed Arrays and\or determine the array length on creation. The following are the two jarray methods:

array(sequence, type):
Creates an array of a specific type with values from the sequence; the array is the same size as the sequence

zeros(length, type):
Creates an empty array the length of the length parameter

The follwoing line in my code:

bytes = jarray.zeros(length, 'b')

Is the jarray, Jython implementation of the following java code:

byte[] bytes = new byte[(int)length];

Friday, August 7, 2009

Start, Stop, Restart Apache HTTP Server on different Linux distributions


Switching from one Linux distribution to another I keep bumping into these minor differences. For instance, here is how you start\stop\restart Apache the different Linux distributions I work with.

Ubuntu (Debian)
/etc/init.d/apache2 restart
/etc/init.d/apache2 start
/etc/init.d/apache2 stop

Red Hat \ Fedora
/etc/init.d/httpd restart
/etc/init.d/httpd start
/etc/init.d/httpd stop

CentOS
/sbin/service httpd restart
/sbin/service httpd start
/sbin/service httpd stop

Feel free to comment with ways to do this on other distributions.

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:

<headless-server>true<headless-server>

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:

-Djava.awt.headless=true

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