Apache Redirect Permanent and ProxyPass

July 02, 2010
You have a Apache running and you have a permanent redirect configured. For example;
Redirect permanent /subfolder/ /
This would redirect www.yoursite.com/subfolder to www.yoursite.com.

Then later on you to add proxy config:

ProxyPass / http://localhost:8080/site/
ProxyPassReverse / http://localhost:8080/site/
ProxyPassReverseCookiePath /site /


But after that your redirect fails. It turns out that ProxyPass config overrules Redirect. Add exclusion to the ProxyPass to fix this:


ProxyPass /subfolder !
ProxyPass / http://localhost:8080/site/
ProxyPassReverse / http://localhost:8080/site/
ProxyPassReverseCookiePath /site /


Note that the exclusion is before others.

Frame rate tool for OS X - ReelSnail

June 28, 2010
I have been experimenting with both DSRL video and Objective C. The result is a simple tool to modify the frame rate metadata in Quicktime h.264 files. This kind of tool is handy when I need to import 60fps file to 30fps or 25fps iMovie project. This results nice slow motion effect otherwise hard to achieve in iMovie.

The project is based on Python script that did the same in command line. But I wanted to add a OS X native front end and I also wanted learn Objective C so I decided to rewrite the whole thing in Objective C. I managed to get most of it working in a weekend. I had one old Cocoa book (Hillegass - Cococa Programming for Mac OS X) and Apple's online guides. XCode and Objective C were pretty different compared to Eclipse and Java but I managed to get my head around some of the concepts.

Another new experiment for me was to use Git for the project. I used GPLv3 for the project because the original Python version used that. Being open source project it was possible to set the repository to GitHub for free. Having gone through some nasty merges in SVN I wanted to try out distributed approach. In a one man project there is not too much to merge but I was curious to try out Git tooling. I ended up using both command line tools and GitX.

ReelSnail project wiki
ReelSnail downloads

Hacking Canon IXUS 60

March 27, 2010
I got some nice features like time lapse shooting and it wasn't even difficult with CHDK. Full story at Apertoire blog.

Media convergence, publishers and Apple iPad

January 27, 2010
Today I checked what is the Apple's new iPad all about. A very nice looking tablet as expected but I was more curious how the content available for iPad will look like. This device comes with browser so normal web content is available as usually. Books, tunes and videos are sold via Apple's own stores. But the announcement featured 'The New York Times' app and that shows where the progress is taking us.

Traditional web or mobile optimised version of the print publications wont cut anymore. Some publishers have announced their own iPhone application but many of them are simple page flipping applications. Not much difference to PDF reader. Seamlessly embedded videos and photo galleries are not that common as one would expect. Especially when new devices like iPad support much larger screen and computing power than previously so they should be able to handle them easily.

At the moment many of those magazine or newspaper reader applications are free with their content but paid content will definitely become more popular. Instead of subscribing or buying physical printed magazine you would receive an access to the extra content - all edited and formatted in a single package. Simple 'subscribers only' area with content snippets lying around might have been the way to do previously but now users are expecting much more elegant presentation. I see iPad and similar devices as premium content platforms and their users are already used to pay for applications, videos and music.

There are two sides of the iPad publishing - a CMS and a reader. Recent development on digital photography has enabled photo reporters to shoot both stills and video - actually they expected to do so now. Presenting this variety of media formats is not straightforward. Publishers had to find way to add all this content in to their sites and I can imagine how their CMSs are being pushed against the limits. Publishers need to have highly flexible content management system that handles vast amount of different media formats and is able to transform them to another (i.e. downscaling videos). The same content needs to be available for normal web, lightweight mobile devices, smart phones and now also for tablet. The extra effort and cost required for each platform version should be minimal.

The content reader can be either the standard web browser or a custom reader application. Publishing content for specific application allows much more freedom for layout and media formats. is an example of how a digital magazine would look like in the future. Developing such reader application is not trivial task but I assume iPad SDK has some new features supporting this. Unfortunately the documentation is available only for members of the iPhone Developer Program.

As Apple did not announce their own de facto reader for rich content there is now an open space for iPad developers to conquer. The solution offering the intuitive user interface on iPad, excellent performance and seamless integration with content management systems will be a winner.

Some file organizing with Python

December 09, 2009
It has been a while since my last Python session but couple days ago I had a perfect opportunity for some Python scripting. The initial situation was that we had tons of files in a single directory. File names were UUIDs so the idea was to create subdirectories and move each file in right directory. We planned to have three levels of directories based on the first characters of the filename. So something starting with 4c14 would go under 4/c/1/.

I implemented this in two parts. The first part created the required directory structure:

import os

workPath = "/tmp/test/"
for a in range (0, 16):
   os.mkdir(workPath+hex(a)[2:])
   for b in range (0, 16):
      os.mkdir(workPath+"/"+hex(a)[2:]+"/"+hex(b)[2:])
      for c in range (0, 16):
         os.mkdir(workPath+"/"+hex(a)[2:]+"/"+hex(b)[2:]+"/"+hex(c)[2:])


The next part was to move files to the corresponding directories. This was also quite straightforward but I had problem with os.rename and I had to replace it with shutil.move. The original script worked fine on my home computer but the development server had the source and destination directories in different filesystems. Here is the final version:

import os
import shutil

sourceDir = "/tmp/files/"
destDir = "/tmp/test/"

filenames = os.listdir(sourceDir)
for filename in filenames:
   sourceFile = sourceDir+filename
   print(sourceFile)
   destFile = destDir+filename[0]+"/"+filename[1]+"/"+filename[2]+"/"+filename
   print(destFile)
   shutil.move(sourceFile, destFile)

These did not take too long to make and most likely someone who remembers Python libraries better would have done it in a fraction of time.

Some Google Wave invites to give away

October 25, 2009
In case you are interested, drop me an email. You should know the address :-)

Problems with JSON and trailing comma with IE6

July 29, 2009
At work a GWT project was modified to use JSON instead of GWT RPC. It worked fine on FF3 and Safari but failed horribly on IE6. The error message was not too helpful: (TypeError): 'null' is null or not an object number: -2146823281 description: 'null' is null or not an object

To investigate this I installed Fiddler to check responses sent by the server. It turned out that our JSON collections had an extra comma after the last item. This trailing comma caused IE to expect yet another item.

Such a small and easy to fix problem but rather tricky to find - but that is life of a programmer.

Some experiences with JBoss Cache as Hibernate second level cache

May 28, 2009
Previously I did some initial setup for JBoss Cache and now I have tested it a little bit on a cluster setup. The setup has two virtual linux images with JBoss 5. In front of them is Apache HTTP for proxying and load balancing.

I started up JBoss on both machines with -c all. This setup has clustering turned on as a default so instances found each other and established JGroup communication channels. Then I deployed the .ear file directly to the deploy directory on each server as the farm deployment did not look too promising. The Apache proxy and balancer were already correctly configured so cookies and sticky sessions worked fine.

The big question is naturally how the performance improved. First I ran a load test without second level caching or query caching in order to have a baseline for comparisons. Then I turned Hibernate second level cache on and executed the same load test. The results were showing around twofold throughput as the average response times halved. I also tried turning on query caching but I did not experience any significant difference with it. Maybe I did not have proper configurations.

I also learned that it is not a good idea to modify data on the DB used by the cluster with Hibernate second level caching on. The nodes communicate sending invalidate messages to each other when data is changed and needs to be refreshed. Modifications outside the cluster mean that the cached data is stale but nodes do not know about it and resulting various errors...

Hibernate second level cache with JBoss Cache 3

May 25, 2009
The project I have been working on lately is a web application running on JBoss 5. The production setup contains a cluster of JBoss instances behind Apache proxy which acts as a load balancer. So far load testing results have been encouraging and load tests also revealed couple bugs.

Our persistence layer is using Hibernate so the next step in caching was to enable Hibernate's second level cache. There are various options but in our clustered environment JBoss Cache was the choice. But getting started with it took some time.

The easiest way is to use 'all' server setup from the JBoss 5 and enable second level cache in Hibernate settings. The JBoss community wiki page provides an example for the setup. Also your JPA entity annotations or mappings need some changes as well because you need to define caching strategy for them.

Taking a look at the documentation of JBoss Cache reveals huge amount of configuration options. Luckily only some of them are relevant for Hiberante second level caching. Be aware that JBoss Cache has been around for some time so some of the older tutorials and blog posts are outdated. At the moment JBoss Cache version 3.x is the recommended one.

In case of caching it is very important to run proper load tests after each configuration modification to verify the performance gain or loss. At the moment I have my test setup running on Apache JMeter. It creates similar load to the server based on historical usage data. Another area of testing is to verify that cluster's caches are having their state updated properly.

I have been experimenting with JBoss Cache only for a day so it will take a bit more time before I can give my opinion or better advices. So, follow my RSS feed to learn more - hopefully soon there will be an update.

Learning Flex

February 28, 2009
After months of GWT and GXT at work I wanted to see how the other side looks like. In my case that would be Flash based rich internet applications. Long time ago I did some experiments with Open Laszló but I did not really get into it.

Now I decided to check Flex so I downloaded free Flex SDK and started with some simple examples and tutorials. Building user interface seems to be quite easy but there are a lot of things I have tried out, yet. Learning server connections using Blaze DS is on my TODO as well as trying out Maven with Flex.

So far Flex seems to be quite easy to get started with as soon as you understand the difference between MXML and ActionScript. The syntax of ActionScript 3 is not too bad for Java programmer. I also bought Flex on Java book from Manning with 50% discount so maybe I end up getting serious with Flex.

Testing GXT grid with Selenium

February 12, 2009
Grid is a fast and versatile component of GXT. Testing it with Selenium is quite simple but requires couple points to be handled. After some thinking and experimenting I came up with following.

First of all, you will need Firebug or similar tool to inspect DOM created by GXT. A suitable example of Grid is http://extjs.com/examples/grid/grid.html. Simply open that URL and open your Firebug.

We are interested to check that Nokia's stock symbol matches NOK. By inspecting the symbol column cell for Nokia we see something like this:

<div class="x-grid3-cell-inner x-grid3-col-symbol">NOK</div>

We can use the 'x-grid3-col-symbol' as a CSS locator. The syntax in IDE is then 'css=div.x-grid3-col-symbol'. This selects the column but the we should also specify the row.

This can be done by creating a new class extending GridViewConfig and overriding getRowStyle method. This method should return suitable value (for example name from Model). You might want to add a postfix or prefix to the value to avoid conflicts. The value becomes part of the CSS style for the row. Set your own instance extending GridViewConfig to your Grid's using myOwnGrid.getView().setViewConfig() method.

Now you should be able to pin point a specific cell using Selenium locator with two CSS classes: 'css=div.x-grid3-col-symbol div.row_nokia'

Stable Selenium test cases

December 16, 2008
After fighting with our test suite of roughly 40 Selenium tests I finally managed to get them all passing on the build machine. The test cases were created with Selenium IDE and saved in HTML format. The build machine has Hudson and it executes the test suite.

To have tests as stable as possible there are some points to watch out:

In case of AJAX application timing issues are a major problem. One option is to set test speed to slow enough. The obvious downside is that the test suite takes forever to pass. The other option is to use pause or waitFor commands in the test case. This requires more effort from the test case writer or recorder.

Not all Selenium components are equal. Selenium RC, IDE and Core all have a bunch of minor variations. For example clickAt command works nicely on IDE but on Core you might want to try mouseDown. And don't get me started about right clicks.

Last but not least is the external input. Another developer playing with mouse cursor while test runs on the browser might cause focus loss and test case failure. The only clue of this is randomly failing test cases.

There are some alternatives for Selenium but I have no clue how well they compare against Selenium. I am not 100% happy with Selenium so alternatives are welcome.

Edit: Hudson is an open source continuous integration tool. It supports on demand builds and scheduled builds, so you can set it up to run a full Selenium test suite during the night.

Selenium testing for Ext GWT/GXT

November 08, 2008
Ext JS blog has a post about testing web application with Selenium. It provides quick overview of Selenium and gives instructions how to set it up. For me the most interesting part of the article was the example Selenium test case code.

At work we have been using Selenium to create acceptance tests for Ext GWT application and it has been quite painless so far. In our case the most important factor was to set id's for fields we wanted to test. That makes locating the right field in Selenium much easier. Another issue was the right mouse click because the application has some contextual menus. The Selenium IDE does not register right clicks properly so it was necessary to modify those actions manually to use mouseUpRightAt.

Yesterday I was wondering how to handle Ext GWT DateField's date picker in Selenium test and I ended up typing the date value in the field instead of clicking the calendar icon. After mentioning this to my colleague he told me to check the blog entry above. From the example I learnt about /following-sibling::img. It seems to be the way to handle trigger fields nicely - something to try out next week.


GWT in Practice reviewed

October 28, 2008
Available on Java User Group Scotland website, GWT in Practice.

Stack Overflow Joy

October 22, 2008
The first time I saw something about Stack Overflow was while I was reading Joel on Software. Couple days ago I finally created my account there and started using it. So far my impression has been very positive.

Stack Overflow is basically just a question-answer site for software developers. But because of its active user mass good questions are replied rapidly and bad ones are moderated. Users receive more privileges the more they are writing good questions and answers.

What is a good question or answer then? That is up to other users who can vote, edit or close your entry.