Wednesday, December 17, 2008

SSH Tips-and-Tricks

I have some ssh tips that I'm using time to time to connect to the university servers. This is cool because I can use the software from the university labs while being at home. So I don't need to drive 20 km both ways just for a single experiment.

X11 forwarding

You can encrypt X sessions over SSH. Not only is the traffic encrypted, but the DISPLAY environment variable on the remote system is set properly. So, if you are running X on your local computer, your remote X applications magically appear on your local screen.

You can enable X11 forwarding with ssh -X host.

Compressing data

SSH can use gzip compression on any connection. The default compression level is equivalent to approximately 4x compression for text. Compression is a great idea if you are forwarding X sessions on a dial-up or slow network. Turn on compression with ssh -C.

Roaming behind the firewall.

Suppose you have to connect to machines, that are located in some remote place behind a firewall. The gateway "G" is a remote server that has the authority to connect to those machines.

What we would like to do is to use any kind of X11 UI on workstation A, for instance. We need two ssh tunnels to connect to the workstations. With the first tunnel we will remap the local port using -L option. The general syntax will be:

ssh -L{local_port}:{workstation}:{remote_port} {user}@{hostname}

After this the gateway will become transparent for us. The second tunnel created for localhost will actually go forward to the gateway and connect to {workstation}.

ssh -X -o "HostKeyAlias {workstation}" {user}@localhost

Given the example above, let's try to connect user "ant" to the workstation "corona" via "aragorn" gateway. Note that we want to use X11 forwarding to be able to work with graphical environment. There are several ways to do this. I'll describe two possible solutions here (assuming that you have M$ Windows running on your PC).


With Cygwin environment one may get the connection to the workstation using following steps.

  1. Start cygwing environment

  2. Start X11 environment, type strartx

  3. Ensure you have at least two xterm windows. Type xterm & to start another xterm

  4. Create first SSH tunnel: ssh -L2222:corona:22 ant@aragorn

  5. In another xterm window create the second SSH tunnel: ssh -X -C -o "HostKeyAlias corona" -p 2222 ant@localhost

To verify is the X forwarding works fine, just type any app. name to the remote xterm, like xclock - and the xclock application should open on your machine while actually running on the remote host.

WinAxe + Putty

If you don't have cygwin environment installed and you're unwilling to install it, then we have another solution here. WinAxe and putty can be used to create the same SSH tunnels as with cygwin. Follow the steps:

  1. Install WinAxe, and run XSession

  2. Start putty, specify the connection parameters and create a tunnel as shown on the pictures below.

  3. Start another putty window and create new tunnel against localhost with X-forwarding enabled.

After putty sessions are started you can do the same trick again as with cygwin, start a remote application so that it looks like running on your machine.

Tuesday, December 2, 2008

Oracle 10g JDBC driver and BigDecimal.toString()

I would like to share an issue with you regarding Oracle 10g JDBC driver and migration to Java 5.

Recently we encountered a production bug where a client got some extra money on his/her account. The bug appeared with Oracle JDBC driver (ojdbc14.jar) version once we migrated the application to Java 5 from Java 1.4.

In order to safe the precision in Java it is the common practice to use BigDecimals. Oracle driver, while binding the objects to SQL types, is calling BigDecimal.toString() method. In Java 5, the method was altered in order to support JSR-13:Decimal Arithmetic Enhancement standard. This issue exists in Sun bug database

Here's a piece of code to reproduce this problem:
-- table for the test
create table test_table ( value number )

// java code to reproduce the behaviour
import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
public class HelloFromOracle {
public static void main(String[] args) throws Exception {
Connection connection = DriverManager.getConnection("jdbc:oracle:thin:user/passwd@DB:1521:SID");
String query = "insert into test_table values (?)";
PreparedStatement stmt = connection.prepareStatement(query);
BigDecimal bd = new BigDecimal("0.000000000000001");
stmt.setBigDecimal(1, bd);

Now, with Oracle driver v the value in database will be:
> select * from test_table

... And with Oracle driver v
> select * from test_table

So my message is to replace the Oracle driver to, especially with migration to Java 5 from Java 1.4. What is interesting is that oracle driver doesn't suffer from this problem.

Thursday, November 20, 2008

Code Kata: The Business Rules

I'm thinking of an application for JBoss Drools. We are given a task to design a system for order management (OMS), which will sit behind a FIX gateway and serve several internal and external systems. One thing is for sure - we are to take a challenge to organize and maintain a large set of business rules and this brings up some memories.

In 2004 a colleague told me about code kata. These are the good exercises to do when learning a new language, or just empirically solve some common problems. One of the puzzlers sit in my mind permanently since then - The Business Rules Kata, which is about the hard to maintain complex business rules.
How can you tame these wild business rules? How can you build a system that will be flexible enough to handle both the complexity and the need for change? And how can you do it without condemming yourself to years and years of mindless support?

We face all these problems daily while coding the business logic for our banking system. One of the approaches some developers have taken is that
the if-the statements can be avoided while using appropriate OOP techniques

The problem is that sometimes while avoiding those if-statements the code becomes over-engineered due to a large number of classes. And it is still doesn't solve the problem of quick changes that are very hard to implement in a big organization with the "release process".

Recently I've found a discussion at It is dated 2005 but I think not much have changed since then. I think that most of the developers are still fighting the complexity of the business rules and in future it will still be a challenge.

My next step is to create a demo using JBoss Drools, QuickFIX/J. Apache Camel can be used to integrate both into one flow.

Also what is really cool about Drools is that it would allow our clients to maintain the order validation rules apart of the overall release process using Guvnor. So the changes in order validation logic could be introduced rapidly.

The TAGRI Approach To Ducumentation

I found a nice blog post called Developers Aren't Gonna Read It about the software requirements documentation principles, which actually refers to Scott W. Ambler's post called The TAGRI (They Aren't Gonna Read It) Principle of Software Development.
The idea behind these posts is that the developers do not read documentation. And to be honest - yes! it is true! I don't remember myself reading the documentation for a long time. In fact, I don't remember if I really have read a single document produced by analyst from start to end. Thinking of the man-hours spent on the documentation by analysts it may be horrible to calculate the total cost that was spent to produce these documents.
I was responsible for the web UI part of this system (100 pages) but had to understand also how the backend works (200 pages). ... So, did I read the documentation? I didn't. I didn't have to because I preferred direct communication with the guys who know the system throughout.

Indeed, a very familiar situation.
Not all documentation sucks. ... the best documentation is the one that is very easily changeable. Wiki is the best option here - it's easily searchable (through many projects) and changeable.

I love wiki! IMHO, it is one of the best approaches to the communication and to hold the documentation, tips-and-tricks, tutorials, etc.

To me, the best solution is to really communicate verbally. Make it to the whiteboard and draw some concepts together with the analyst. It ensures we both use the same terms, and both understand the domain of the problem. I hope our team members feel the same.

Tuesday, November 18, 2008

Creating Database Link (aka DBLINK) in Oracle

I had to mess with Oracle database links recently. Here's a good reference to the "CREATE DATABASE LINK" sentence syntax.

In my case it was:

'mydb' has to be an entry in ORACLE_HOME/network/admin/tnsnames.ora file on the server side Oracle client installation, so that the host database can see the foreign one (which is 'mydb').

Next, make sure that sqlnet is configured to use tnsnames.ora file. Its configuration is defined ORACLE_HOME/network/admin/sqlnet.ora, which contains client side network configuration parameters (again, on the server side!). For instance:


Next, we could test this database link:

SELECT * FROM dual@mydb;

Now it makes sense to use a synonym to point to the foreign table.


Now the initial query will look as follows:


Saturday, November 8, 2008

GWT vs Flex

We have now some experience with GWT while implementing an enterprise price management system's UI. There are some nice features that GWT provides, but there are a lot of pain also while using some 3rd party widget library, like GWT-Ext. In my mind, the main problem is that while coding the solution using GWT, you loose the feeling of the application (especially if using a wrapper around a native JavaScript library). But this is just my feeing and doesn't really show if GWT is bad or good. Related to the real problems, when we had too many records to render in a data grid, we faced some performance problems - rendering all the records took quite a time and stalled the browser instance until the end of rendering process.
The 3rd issue I find relevant is the amount of code had to be produced for the layout and interactive behavior of the application. The Swing-style coding is a real blocker. IMHO, GWT probably make heavier use of annotations, perhaps even introduce some custom annotations for simplifying the implementation of user actions (i.e. listeners as inner classes).

After we almost finished the prototype, I started to think that probably, GWT is not really what we'd like to use in our application for the UI. I'm still strongly convinced that for this application we need a rich UI to satisfy the user. Adobe Flex was the next technology in our list. More than that, Flex is approved for our internal development by the architects council. So one our colleague presented us how is he using Flex to implement a RIA for loan management.. and smashing!!! I really liked the code separation for the UI: layout is defined in MXML files, events for the UI components are defined in a separate ActionScript files, and some utility code can also be separated into other scripts. Further more, the speed of making a convenient application was really fast. And also the amount of code to be written is much less than with GWT. No layout problems in the resulted swf, rendering a data grid with thousands of rows was just blizzard-fast compared to JavaScript analog.
I found some comparisons of GWT, Flex and Echo2 on the web: one and two
Both GWT and Flex 2 are Rich Internet Application (RIA) frameworks whose code is downloaded and executed on the client side, in the browser. GWT compiles Java code to JavaScript whereas Flex compiles a combination of ActionScript and MXML code to a Flash swf file.

And here's the quote I was waiting for:
...both GWT and Flex 2 have different situation where they each are better suited. HTML, CSS, JavaScript are still the best option when developing a web application intended for the general public. Flex 2 is would fit well when developing flashy business minded applications with a targeted audience.

I think this describes our case the most - a targeted audience.

Friday, October 3, 2008


Lately I've started to put pressure on my studies. One task I have taken for now is to extend an old academic application (C++), which involves improving the internal format, as well as the interfaces between sub-programs, etc. It is also due to some integration possibilities that we have to rethink the design of the application.

Now, so far I have no experience with C/C++ application development. Java is no-go, as the other academic tools in our landscape (embedded systems) are mostly C++. Therefore I'm thinking that I need some workaround here in order no to violate the overall structure and do it as quick as if I would do it in Java.

As one of my goals is to create a grammar-based input to the application, the natural choice for me is ANTLR. It provides many targets for the input grammar, C++ included. Now if I'm trying to escape C++ coding, and Java is not the language that is appropriate for this task (I think), then I'd rather pick some scripting language.
Python has a nice extension mechanism as well as ANTLR v3 supports the Python target. Also, it is claimed that the Python learning curve is quite flat, which makes sense in my case.

I've found a great tutorial on the C extensions for Python. What amazes me the most, is the ease of the extension compilation. One way is to compile it using gcc from command line. But the other way is to create a simple Python script ( which will do everything for you:

from distutils.core import setup, Extension
module1 = Extension('extension_name', sources = ['myfile.c'])
setup (name = 'PackageName',
version = '1.0',
description = 'my demo package',
ext_modules = [module1])

Now the script can be executed in the same directory where the myfile.c resides: python build.

The only thing I had to do extra on my machine is to install the python-dev package via the Synaptic Package Manager.

What I want to do now, is to create a C++ class hierarchy to model the internal format of the current application, then wrap it with some C++ code that will convert Python types to C++ types and vice versa. And after that I can create a Python binding and ANTLR grammar with Python target to convert the input format using Python code into the C++ classes. Bingo! :)

Thursday, August 28, 2008

JetBrains MPS

Now this is a killer! The Meta Programming System brought by JetBrains is a really nice full-featured DSL development environment where you can design your own language from ground up, including the specific editor and other features along with code generation and even refactoring support!

MPS Screencast by Sebastien Arbogast.

Saturday, August 9, 2008

More Widgets for Guvnor

For properties and XML editors in Guvnor I'm trying to make use of GWT-Ext components. The widgets from this library look really nice. Also the API looks OK. For the properties widget, theres a PropertiesGridPanel available, which provides some nice features for editing the properties (see the screenshot below).

.. and a piece of code that assembles the panel:

PropertyGridPanel grid = new PropertyGridPanel();
GridView view = new GridView();
Map map = new HashMap();
PropertyHolder[] props = getProps(); //RPC call here
for (PropertyHolder holder : props.list) {

How does it know which editor should be attached to the value column? Simple the type is known at the compile time! One of the benefits of GWT is claimed to be its performance. It is fast, but this power comes at a price - you cannot leave the type undefined, i.e. you cannot use java.lang.Object for the type of your class members.

Consider the following class, which is intended for exchanging the information via RPC calls:

public class PropertyHolder implements IsSerializable {
public String name;
public Object value; // coudn't use Object type here

While trying to compile this code down to javaScript, we'll get the following messages from the GWT's compiler:
[java] Analyzing the fields of type 'org.drools.guvnor.client.ruleeditor.PropertyHolder' that qualify for serialization
[java] public java.lang.Object value
[java] java.lang.Object
[java] [ERROR] In order to produce smaller client-side code, 'Object' is not allowed; consider using a more specific type
[java] [ERROR] Type 'org.drools.guvnor.client.ruleeditor.PropertyHolder' was not serializable and has no concrete serializable subtypes

So that's it! I couldn't think of any solution how to cheat the compiler and leave the value's type undefined, so I have to use strings for now.

Friday, July 25, 2008

GSOC2008: The Pluggable Editors for Guvnor

One of the goals in this year's GSoC project for me is to enable plugging of content editors as jars. Today I've completed the automation for this aim.

I've integrated the rolodex widget for using image data in Guvnor. Next, the aim was to isolate the code into a separate place, so that it doesn't affect the base source code, and using some code generation routines integrate the new widget to Guvnor.

Here's the summary:

  • The pluggable code is moved into modules/ directory under drools-guvnor

  • build.xml was extended to generate some code pieces to integrate the pluggable editors. Some classes in Guvnor required a minor refactoring in order to support code generation.

It is not as smooth as it could be in GuvnorNG, but the goal is achieved to some extent, I think :)

Friday, July 18, 2008

GSOC2008: Rolodex Panel Assembly for Guvnor

In my previous post about integrating rolodex into Guvnor I tried to create the example just with a set of pre-compiled images which are then assembled into drools-guvnor.war. But the real goal is actually to display the pictures stored in Jackrabbit repository for Guvnor.
Now, after some experiments with rolodex and Guvnor, I have a widget where one may upload a picture and display it.

Currently it can accept only one picture per RuleAsset class instance. Therefore the content handler for this asset should be extended to support multiple images per RuleAsset.

RolodexCardBundle images = getImagesFromAsset();
RolodexCard[] rolodexCards = images.getRolodexCards();
if (rolodexCards.length > 0) {
final RolodexPanel rolodex =
new RolodexPanel(images, 3, rolodexCards[0], true);

I have set the hight of the panel manually as the picture was cropped otherwise in the widget. (Don't know the reason yet). getImagesFromAsset() is used for converting the asset's content to the RolodexCard:

public RolodexCardBundle getImagesFromAsset() {
return new RolodexCardBundle() {
public int getMaxHeight() {
return 200;

ClippedImagePrototype clip = new ClippedImagePrototype(
GWT.getModuleBaseURL() +
"asset?" + HTMLFileManagerFields.FORM_FIELD_UUID +
"=" + asset.uuid
0, 0, 300, 200 );

RolodexCard card =
new RolodexCard(clip, clip, clip, 300, 100, 10);

public RolodexCard[] getRolodexCards() {
return new RolodexCard[]{card};

I've cheated with the code that composes the RolodexCard, as ClippedImagePrototype's javadoc says:
This class is used internally by the image bundle generator and is not intended for general use. It is subject to change without warning.
But the implementation of ClippedImagePrototype is actually what I need. Probably, if it is really the subject to change at any time, I would rather cope'n'paste this class into Guvnor code base.

A heavy part of the work will have to be carried out by the content handler. The content handler will have to support the multiple images per asset and also perform some graphics routines in order to replace the pre-compilation phase implemented in rolodex to adjust images.

Tuesday, July 15, 2008

The time applet in Ubuntu

Recently I discovered that there's one cool feature in the GNOME's time applet: the Locations tab. There I can specify my location and customize the applet look. One interesting feature attracted me the most - the "weather" label. I can see that the weather is if I take a look out of the window. But I think I couldn't say exactly how cold/warm is it - and the applet can show me this information. Small but neat feature I have to say! :)

GSOC2008: Integrating Rolodex to Guvnor

In Guvnor, there are many different widgets that are used to display or edit different assets. One interesting widget is about to be added - a widget that could accept images and display them. For this purpose, rolodex, a widget that can display a stack of images, can be used. Rolodex uses deferred binding for the image generation and animation. Let's see how can we quickly add a new widget displaying some predefined images.

First, create a class, implementing RolodexCardBundle interface (from the rolodex library) and declare a few methods that will return the images (just like ImageBundle described in the book):

public abstract class Images implements RolodexCardBundle {

* @gwt.resource img_3861.jpg
public abstract RolodexCard imgA();

* @gwt.resource img_3863.jpg
public abstract RolodexCard imgB();

* @gwt.resource img_3865.jpg
public abstract RolodexCard imgC();


private final RolodexCard[] cards = new RolodexCard[]{
imgA(), imgB(), imgC()

public RolodexCard[] getRolodexCards() {
return cards;

Next, to display those images, create ImageSetWidget (or you-name-it) class extending DirtyableComposite:

public class ImageSetEditor extends DirtyableComposite {
// asset and viewer are not used now...
public ImageSetEditor(RuleAsset asset, RuleViewer viewer) {
final Images images = (Images) GWT.create(Images.class);
final RolodexPanel rolodex
= new RolodexPanel(images, 3, images.imgA(), true);

For Guvnor to be able to launch the editor, we have to modify EditorLauncher class:

else if (asset.metaData.format.equals(AssetFormats.IMAGE_SET)) {
return new ImageSetEditor(asset, viewer);

AssetFormats should be supplied with the new constant for this new type, of course.

To allow user to create such widgets in UI, a new menu item needs to be added.

This means, ExplorerLayoutManger#rulesNewMenu() should be modified:

m.addItem(new Item("New ImageSet",
new BaseItemListenerAdapter() {
public void onClick(BaseItem item, EventObject e) {
launchWizard(AssetFormats.IMAGE_SET, "New ImageSet", true);
}, "images/rule_asset.gif"));

And last, but not least we need to include the following line in Guvnor.gwt.xml:
<inherits name='com.yesmail.gwt.rolodex.Rolodex'/>

Now, after the project has been rebuilt and redeployed we get the following widget on the screen:

Currenly, the widget is displaying a predefined set of images and animates them as we roll the mouse over. So we have now a rolodex-powered widget inside Guvnor. Sounds cool! :)

Now, there are a lot of TODOs to make use of this new cool widget.

  • Menus should be pluggable. So far I knew that the only class that we should generate in order to support adding new rule editor widgets. Without doubt, a user needs a button to create the widget in his workspace, and therefor we should inject the new menu item. I suppose we can generate this part also. Therefore we need to extract the ExplorerLayoutManger#rulesNewMenu() method into a separate class.
    Currently I have an ant task ready to generate a new EditorLauncher class source to plug a new asset type editor. But perhaps, if we have more of these classes to be generated, I'd better add a new ruby script to do this job.

  • Upload of new images. There's no use of this widget if it can redisplay only the predefined set of images.

  • RuleAsset support for images.The images should be supplied via the RuleAsset, i.e. the content should be a class that could represent a set of images.

  • A content handler is required as well.

Friday, July 11, 2008

Google OSS Jam: Zurich Meetup for GSoC'08

I've spent 3 days in Zürich, again! I really like this city :)

Thanks to Maximilian Albert I'm now aware of Inkscape, an Open Source vector graphics editor, and lib2geom. Thanks to Peter Arrenbrecht a mentor for Mercurial GSoC project, I'm now totally convinced that the DVCS is what I really need, either Git or Mercurial :) And thanks to Stefano Tortarolo, a student from Mercurial, the next programming language in my arsenal should definitely be Python!

Some more interesting OSS projects that were presented at the OSS Jam:

Friday, June 27, 2008

JAZOON 2008, Post Mortem

I think that JAZOON'08 was a real success and this conference has a lot of potential in the future! We have to give a credit to Jürg Eberhard, Christian Frei and the rest for the outstanding organization!
What I really liked about the conference is that many presenters talked about the real projects and proposed solutions, instead of just talking about the standards, methodologies, frameworks, etc.
I would suggest this conference to my colleagues. Furthermore, the location is just right - Zürich - one of the nicest cities I have visited so far!

Long live JAZOON!

JAZOON 2008, Day 3

The keynote was given by Joshua Bloch, Principal Engineer at Google. In Effective Java Reloaded he presented some chapters from the 2nd edition of his book Effective Java. Joshua talked about generics, enums and concurrency.
After the talk he was signing the book, Effective Java - 2nd Edition, which was exclusively available at Jazoon'08. So now I have a pleasure happy to own the book signed by Joshua Bloch! :)

After I've got my book signed I went to listen about the new features in Eclipse 3.4. After the release of Ganymede, there are some very cool features which I probably would like to see in IntelliJIDEA too! :)

Next, Dan Allen was continuing with Seam Framework related talk It's evolution, baby! Bijection deplaces dependency injection. It is a very promising concept on bi-directional dependency management which is widely used in even the simplest Seam web applications.

Later, Heinz Kabutz has shocked crowd with his blizzard talk about threading in Java - The Secrets of Concurrency. No one couldn't even ask a question! :)
Here's one useful idiom that I managed to put down:
try {
} catch(InterruptedException e){
It is funny that "idiom" and "idiot" are quite close - Heinz said :)
The last session I attended The Closures Controversy by Joshua Bloch. To be honest, I like closures ... outside Java! Really, if one is really eager to use these fancy syntactical constructs - there's JRuby, Groovy or Scala available - use them!
Here's just some of the facts I picked up from the presentation. Closures are/have:

  • hard to read

  • produce cryptic error messages

  • don't interact well with autocompletion

  • have two kinds of returns, whereas the real meaning of the return keyword has changed

  • unclear semantics

  • not thread safe

What is really wrong with the inner classes compared to closures? Only that you do not have to make a new class and don't have to create it with the new keyword? I think that inner classes are still better from what we could see with Java closures. Closures are for dynamic languages which can be used in conjunction with Java! So I'm strongly opposed to the idea of including this feature into Java language. Java has to stay clean! Unfortunately it has already been rubbished with the spoiled implementation of generic types :(

Wednesday, June 25, 2008

JAZOON 2008, Day 2

On the second day of JAZOON ...

The opening session

Rethinking Enterprise by Ted Neward (Neward & Associates) was a great introduction to the day! He pointed out the things that I'm talking about to all my relatives and friends - the education system sucks! The problem is that almost everything that we learn in school we forget. And this is just because of the system - we are presented with some theory and then we are tested on that theory using some problem statement, and after that - nobody cares.
One great statement I put down - "The problem and its solution are never apart". And this statement actually describes the problem above - at schools we are never forced to think beyond the theory which we just learned.
This was also a funny talk with some jokes about the "long-haired guy". This is a good one - Ted said (jokingly of course):
I know how to make copy-paste in PowerPoint, because I am an architect!

Open Architecture by Roy T. Fielding (Day Software). This was a little boring talk, but to say the least it was truly right talk. I mean all the things that Roy was talking about are valid I think - of how the open architecture matters for open source software, how the ecosystems work, etc.
Now I know what the Conway's Law is.
Any organization that designs a system (defined broadly) will produce a design whose structure is a copy of the organization's communication structure.

And also after Roy's talk I would like to try what can Apache Sling do.

Spring Framework 2.5 - Selected New Features, Juergen Hoeller (SpringSource). This was a neat overview of Spring's AOP and the new features that can be implemented with Java annotations. Basically I could read everything he talked about in the web, but it is quite nice to get it to know from "the source".

Then I attended the session called Stacking the deck by integrating Spring beans and Seam components by Dan Allen (TetraTech, Inc.). The point was that we can use Spring in co-operation with Seam in order to wire up JSF pages to the underlying beans, and this avoid using the expression language (EL). The talk was quite interesting and very technical too. It seems to me that the sessions that are somehow related to JBoss are the most interesting ones @ JAZOON.

JSR-303: From a world of Constraints to Constrain the world by Emmanuel Bernard (JBoss). Again, the JBoss related topic was just the right session to choose. Emmanuel was talking about the beans validation (JSR-303) which can be implemented using Java annotations. He also pointed out that there should be a clear separation between bean validation and conversion (and I do agree on that).

I noticed that theres a huge trend for most of the topics - the Java annotations. Almost in every presentations the authors wanted to implement things using annotation-based configuration. Perhaps, this is the real hype of meta-programming in Java community.

An interesting type of presentations is the one where the author is presenting a deployed solution and talking about the problems he faced while implementing the system. At the talk called Distributed client/server Java Persistence by Alexander Snaps (Axen/Alten Group) the author was presenting his solution for offline clients with centralized database. He also mentioned a new framework he implemented for this purpose - Hölchoko (need to have a look on it).

And the last session I attended was Cluster your POJOs with PojoCache by Bela Ban (JBoss). This was just perfect as always :).

Tuesday, June 24, 2008

JAZOON 2008, Day 1

The first day @ JAZOON is complete!

The opening session.

  • At the talk called The Challenge of Scalable Languages, Martin Odersky (the creator of Scala) was talking mainly about Scala language and how does it relates to Java. Explaining some of the design decisions for Scala (at last, I've got the answer for the silly declaration construct in Scala, i.e. var x: Int). There are many nice features in Scala I think. But I do not really understand why the operator overloading is brought in again?! Operator overloading was the feature that Java designers wanted to get rid of after C++, because when you read the A+B you cannot be sure weather the operands are really numbers.

  • Simon Phipps was talking about The Adoption-Led Market. He started with Sun's relation to open-source, continuing with open-source history and licensing. This was a good talk with a lot of funny stuff in it. The only question to Sun is that if Sun is so opened to open-source software, why did to closed the source of MySQL engine??

  • Next, Rod Johnson expressed a lot of criticism in respect to J2EE, JCP, etc in his talk Where will Tomorrow's Innovation Come From in Enterprise Java. For sure, he didn't forget to mention the Spring Application Platform :)

Next, Dmitri Buzdin was talking about his experiences with GWT adoption. I piked up that there are some difficulties with GWT, specially for developers who have less experience.

Against all odds - efficient Rich GUI development in Java. This was a talk about the rich UI development for a company called APG that is dealing with billboarding. The current solution was implementing Oracle Forms technology and as Forms is being deprecated, they decided to implement the rich client in Java with Swing.
So basically they were talking about the rewrite of UI without touching the back-end. As the result there's the direct connection from client to the database. I'm not sure how scalable new solution is, but the technology used for implementation is what amazed me the most. The UI is being generated based on meta-data described with some DSL. The framework used for this is the openArchitectureWare. The guys were claiming that this way they increased the development speed compared to the Oracle Forms. I think that the complete solution is a real crap. I can tell why. First, while the demo failed, they showed us the code - it was half-german, half-english code there, i.e. some methods were named in German which I think is a rally bad practice. Secondly, the technology stack which lead from the specification to the implementation is very unclear: if there will be an error, the application developer will be seeking for the problem all the day long instead of writing the real code. And last but not least, they did not finalize the project yet, so it was a little bit too early to talk about its success. I think even if the project gets finalized, if future the cost of maintaining this piece of software will be inadequate.
Perhaps I'm too rude in expressing my opinion to the solution some people may think is really good. May be it is just that I do not understand the MDA really well. So probably I'll take a look at it if it happens that I have nothing else to do :)

AJAX Push for Revolutionary Enterprise Applications presented by Micha Kiener (mimacom ag) and Ted Goddard (ICEsoft Technologies Inc.) was a nice presentation I enjoyed. The technology presented is quite innovative and it looks like pushing a new wave in the area of Web 2.0 application development. The keywords: Ajax Push, Comet, "Reverse Ajax", ICEFaces, Edoras, Servlet 3.0.

The NetBeans Day @ JAZOON

The real name for the event was NetBeans Day - Get to know the only Java IDE you need. I didn't expect it to be very interesting but at the end of the day I can say that there were a lot of good things to pick up from this tutorial. So what was it really about:

  • NetBeans new and Cool by Romal Strobl. At the talk Roman showed what are the new things that were added to NetBeans 6.1 and some tricks and tips how to use the IDE. From my point of view, NetBeans is just copying the best features from IntelliJIDEA and eclipse. The IDE looks nice, the features are reasonable, but isn't it plagiarism in respect to the other IDE vendors?! FWIW, personally I do like NetBeans even more that eclipse.

  • Isolating Performance Bottlenecks and Memory Leaks by Peter Gassmann. This was an in-depth review of NetBeans Profiler which is really easy to use, and specially with Java 6. I have to give it a try! :)

  • SwingApplication Framework and Beans Binding by Roman Strobl. This was about JSR-295 (Beans Binding) and JSR-296 (Swing Application Framework). In fact both of this specs look promising in sense of desktop application development. There's a very good suport for that in NetBeans also, which is cool! But what disturbs me is that in the resource injection, which is claimed to be "automatic", you have to write some code (e.g. call a method setName(String) for a Swing component that needs some some configuration. In my opinion this is not really automatic way to do things and there should be more elegant solution. Writing your own Java code to make things work "automatically" - this is kind of a stupid thing.

  • Incorporating Animation and Media using JavaFX by Rags Srinivas. I cannot tell why but I still being skeptic about JavaFX. It looks lika Sun is positioning JavaFX as a technology for cross-client UI development. That's OK. But as a language, JavaFX looks very odd. For small UIs it may be a nice tool, but I doubt that for the larger apps it will be very complicated to use and the code will be hard to follow. The technology is still in development and Sun promised to finalize it by the end of the year.

  • NetBeans Mobility by Roman Strobl. This is the most interesting feature in NetBeans perhaps that I have seen this time. Constructing the application workflow visually using NetBeans is something I was really missing at the days when I did some J2ME development. Definitely, if I'd had to develop and application for mobile phone today, I'd used NetBeans just for this feature! A very nice feature of NetBeans Mobility Pack is that it provides some basic support for game development, and this is something that I was missing the most!

Roman Strobl was the guy who made the day. The presentations were very well prepared and we gotta thank Roman for that :). The only thing that I would suggest is to add more live coding to the presentations.
So to conclude, I'm quite satisfied with the sessions and I've picked up some useful stuff as well.

Thursday, June 19, 2008

Java on Windows: Windows RegOpenKey(...) returned error code 2.

So we faced a strange warning message being pumped out to the console after deploying a brand new Java application to a Windows machine.
Jun 19, 2008 3:19:20 PM java.util.prefs.WindowsPreferences openKey
WARNING: Could not open windows registry node Software\JavaSoft\Prefs at
root 0x80000002. Windows RegOpenKey(...) returned error code 2.
Jun 19, 2008 3:19:20 PM java.util.prefs.WindowsPreferences WindowsRegOpenKey1
WARNING: Trying to recreate Windows registry node Software\JavaSoft\Prefs at root 0x80000002

After a quick search in google, I found that It might be a bug concerning the restricted users on Windows. There's two options to solve this problem:

  • Add use privileges, as described here.

  • Or, move to Java 5

I think we'll migrate to Java 5 :)

Wednesday, June 11, 2008

GSOC2008: GWT magic - Deferred Binding and Generators

While reading the book further, I realized that I do not need any special library for plugging new content editors to Guvnor.

Currently, the editors are instantiated via EditorLauncher class, which provides several static methods for working with the editors. Now, we could actually remove the static property, change EditorLauncher to be interface and instantiate EditorLauncher like this:
EditorLauncher launcher = (EditorLauncher) GWT.create(EditorLauncher.class)

This will actually force the EditorLauncher implementation to be generated at the compile time using our generator (which would be subclassed from This cool feature of GWT is called deferred binding ...
... which works by resolving and inserting the required class during compile time instead of runtime, as is the case in the Java language.

Basically, the need for any external library is diminishing in this case.

Tuesday, June 10, 2008

GSOC2008: Reflection Libraries for GWT

GWT Reflection appeared to have GPL licence and thus cannot be incorporated into Drools code base :(
I've found another library which has the support for introspection/reflection of Java beans - Gwittir, which comes with LGPL, and thus can only be included as a jar, but actually it doesn't provide the functionality that could provide us the features for plugging the content editors via Java Reflection API. So anyway we need to extend it.
I think I better go my own path and re-implement the code generation myself. There are 2 reasons for that: I will have the better understanding of the mechanisms behind GWT, and also improve my commit rate for the project :)

Monday, June 9, 2008

Sunday, June 8, 2008

GSOC2008: GWT Reflection for Pluggable Content Editors in Guvnor

GWT Reflection is a cool project which inspired Mike for the idea of pluggable content editors for Guvnor (aka JBoss Drools BRMS). The challenge is that the content editors are selected on the client side and therefore we couldn't use Java's reflection API in order to enable the plug-in functionality. But with the GWT Reflection we can probably get as close as possible. GWT Reflection does a lot of what we need but most probably we'll need some more features and therefore I'm integrating it into Guvnor's codebase at the moment. I hope I will have some basic workflow ready next week. Stay tuned! :)

Tuesday, May 27, 2008

GSOC2008: My First Contribution

On the first coding day (or I'd better say *night*) I was surfing Guvnor (former Drools BRMS) codebase. I've noticed some flaws in the code so I did some refactoring to achieve my first commit :) A cyclic dependency between org.drools.brms.server.contenthandler.ContentHandler and org.drools.brms.server.contenthandler.ContentManager was removed.

Friday, May 9, 2008

GSOC2008 in Estonia

While the stats are published only for the Top 10 list at the Google Open Source Blog, it was interesting, how many mentors/developers from Estonia are participating in the program this year.
I have found 5: 2 mentors, and 3 students. The screenshots are below.

So the mentors are: Ahti for one cool project.

.. and Mart Raudsepp for several Linux related projects like wxWidgets and Gentoo.

And the students are here:

A little country, and not many good universities, hence not many participants.

Saturday, April 26, 2008

Web-Based Java IDE Wanted!

I wanted to check some ideas with Java this evening and the PC that was available to me did not hava Java, nor Java IDE installed. I wish there was a web-based Java IDE integrated with my Google account,, and integrated with some Maven repo to fetch the dependencies!

I have googled about this topic and didn't find any reasonable results besides a video about wwworkspace. I couldn't find the service's website, unfortunately. The only reasonable webpage that I've found on this topic is the IBM's effort on the XUL front-end for eclipse: here... dated October 11, 2007. And no further news from there.

In fact this could be a very interesing project, and also very useful. The web-bvased IDE could even be not only Java-oriented but like eclipse, targeted towards different languages, taking advantage of plug-ins. Probably, using eclipse as a back-end wouldn't be that hard to implement? I wonder why there wasn't a GSoC'2008 proposal for this idea (or even if it was, it wasn't accepted)?

Tuesday, April 22, 2008

Google Summer of Code 2008: Application Accepted!

I've got my GSoC application accepted again! This time I've applied to project Drools for extending Guvnor framework. Red Hat got 12 slots in total for Fedora and projects (10 for Fedora and only 2(!) for, Here's the project list. And here's some more stats.

So, happy summer coding to me! :)

Friday, April 11, 2008

Shell History in My Ubuntu

ant@ubuntu:~$ history|awk '{a[$2]++ } END{for(i in a){print a[i] " " i}}' |sort -rn|head
171 ls
134 cd
19 less
17 mogrify
14 rm
12 unzip
10 mv
8 java
7 mkdir

Friday, March 21, 2008

CaseInsensitiveMap and CollectionFactory

The code of the subject:
  Map map = ...;
map.put("hello", "world")
The output:
How could this possibly work?
In the real code, the map was received as a result from org.springframework.jdbc.core.JdbcTemplate#queryForList() method call, and SpringFramework 2.0.8 is in use. As it came out, the ResultSet extraction spans down to the org.springframework.core.CollectionFactory class which purpose is
... to avoid runtime dependencies on JDK 1.4+ or Commons Collections 3.x, simply using the best collection implementation that is available.

That said, there's a dependency on Commons Collections 3.x library. The while extracting the ResultSet received from the query call, the framework asks the factory for the map implementation to accumulate the results and makes a call to CollectionFactory#createLinkedCaseInsensitiveMapIfPossible() method:

private static final boolean commonsCollections3Available =
public static Map createLinkedCaseInsensitiveMapIfPossible(int initialCapacity) {
if (commonsCollections3Available) {
logger.trace("Creating []");
return CommonsCollectionFactory.createListOrderedCaseInsensitiveMap(initialCapacity);
else if (JdkVersion.isAtLeastJava14()) {
logger.debug("Falling back to [java.util.LinkedHashMap] for linked case-insensitive map");
return JdkCollectionFactory.createLinkedHashMap(initialCapacity);
else {
logger.debug("Falling back to plain [java.util.HashMap] for linked case-insensitive map");
return new HashMap(initialCapacity);
private static Map createListOrderedCaseInsensitiveMap(int initialCapacity) {
// Commons Collections does not support initial capacity of 0.
return ListOrderedMap.decorate(
new CaseInsensitiveMap(
initialCapacity == 0 ? 1 :

So, if the Commons Collections 3.x exists in the classpath, we'll receive a CaseInsensitiveMap decorated with ListOrderedMap to preserve the order in which the objects would be isnerted into the map. In its turn, CaseInsensitiveMap stores calls the Object.toString().toLowerCase() method on any key object that is being added, so the keys are always lowercase strings! And this is why the example above was working.

The problem is that if you won't add the Commons Collections library to classpath, and will use lowercase strings to pick the values (i.e. map.get("some_key")), then you will most probably get null as a result, because there's absolutely no guarantee that the column name in the database is in lowercase.

Tuesday, March 18, 2008

Google Summer of Code 2008 Begins

Google Summer of Code 2008 Mentoring Organization List Announced!

Google announced the list of mentoring organizations for GSoC2008. A marvelous number of interesting projects and many famous OSS companies are in the list. ASF, Fedora &,, Codehaus, Jikes RVM and some other are the organizations that I'm interested in. I think that the most suitable project is the one which brings a value once it is complete. So I think I can find such a project within these organizations.

Sunday, January 13, 2008

uCertify's PrepKit for SCBCD5.0

Recently, I had a pleasure to evaluate the uCertify's PrepKit software for the SCBCD5.0 exam. The impression is somewhat twofold. The PrepKit is great software to prepare for the exam, it is easy to use and the GUI is quite intuitive. But along with all the positive stuff, there were some obstacles I found a bit annoying. I will go over all the positive and negative moments as they appeared while using the software.

PrepKit works on Windows only

Certification software is provided by many different vendors and the suits are developed for very different platforms. When one is about to purchase such a software package it would be a good point to verify, if this software will run at his/her computer at all. The uCertify PrepKit software is Windows PC only, and this is what I found frustrating. I use Ubuntu Linux at home and I use wine to run MS Windows-based programs. This time wine failed even to install the PrepKit package: the installation process hanged on a half way and I was forced to xkill it. Fortunately my wife still uses Windows on her laptop so I installed the PrepKit there.

Probably, if the subject of certification is an MS's technology or product, then the idea to make PrepKit run only on Windows is OK. But if the subject is about Java certification, then it is quite strange to cut the Linux users off. Hopefully uCertify will soon come up with Linux version of PrepKit software.

The UI is quite intuitive

What makes the software easy to use? And what makes UI intuitive? PrepKit is aimed to help the user to prepare for the exam and carries the educational purpose for a specific area of interest. The user works with PrepKit via its GUI and is not aware how the software acts behind the scenes. The point is that the user doesn't want to learn about the GUI, but rather interested in the subject of certification. PrepKit GUI controls are organized is such way that user could see everything right from the very first sight.

I could logically divide the user screen in three parts: the tests part (top left), the learning part (right), and the estimation part (bottom left).

PrepKit allows you to take practice tests, quizes, provides explanations on the subject and estimates your progress. Each piece of functionality is well-recognized and thus it is easily located on the user screen.

Where do I start?

There could be several strategies to start using the software, depending on your background. If you have already some experience with EJBs, and you know that is the exam about, it is reasonable to take some mid-level test to see what is your initial level. If you aren't sure to take the test right away, "Enhance your understanding" might be useful to get the overview of the exam, find some additional information and practice a little before you proceed with the tests.

The "Enhance your understanding" part is the subject for improvement

I found "Enhance your understanding" panel very useful for getting more information about the exam itself, and also for improving my knowledge about the subject. From top to bottom:

Exam objectives provides an overview of the exam objectives and general notes about every part of the exam. This is quite useful to understand how the exam is structured and what kind of knowledge is expected.

Interactive quiz is really nice feature! The quiz is sort of a small test that allows you quickly to test your knowledge for the specific subject. It is possible to choose which part of the exam questions you would like to give a try. Say, I want to test my knowledge in transactions, so I could customize the quiz to include only the relevant questions. You will get the result immediately after you answer a quiz question, and you have the option for grading the questions as well - whether you liked it or not (I'm not sure how would it be useful yet).
The thing that the quiz is missing, IMO, is the explanation of the result. I wanted to know why my answer is not correct, but the quiz only shows if the answer was OK.

I did not get the purpose of Flash cards. What is it for? The "flash cards" do not test anything and aren't very different from the Study notes. So why hold them separately? For every flash card you are suggested to write down your knowledge about some specific topic and then compare with some predefined text. Honestly I didn't find any use of that feature.

Study notes are somewhat more useful compared to Flash cards. There are ~250 notes on the different aspects of the EJB technology from different areas of the examination. The notes are provided in question-answer form which seems to be quite natural. For instance: "What is the ejb-jar file?", following with some text explaining the subject.
What I find really useful about the notes section, is that every study note has several test questions associated with it. So when you have read a study note and you would like to practice with the topic, then you have the option to answer the related questions.

There was only one article in the Articles part. The feature is nice but only one available article is definitely not enough. Hopefully the articles section will be extended with the updates.

The very last part of the section is Study tips, which are redundant IMO. This could be actually merged with the Exam objectives part.

The tests are well organized

These include a diagnostic test which aims to identify your weakness and guides you to focus your preparations accordingly. Next, there are some predefined tests, which aim to simulate the actual exam. Also, an adaptive test is available. Depending on your answers the adaptive test aims to provide you relevant questions: if your answer was correct, the next question will be of higher difficulty level, and in opposite, if you fail, the next question will be easier. And the last but not least a user can customize the test content on his own with the custom test.

I also found some things that were annoying me in the tests. Almost every question in tests starts with the following text:
You work as a Software Developer for BlueWell Inc. You create an application using Enterprise JavaBeans

Pardon me, does it make sense if I do work in BlueWell Inc. or not? The statement about writing the EJB application is redundant because I'm already concerned about the subject and there's no point in raising it over and over again. This two sentences just took my time in reading the question while providing no value.

Track the progress and estimate your skills

PrepKit provides some statistical information of the progress of the studies.

So when the user takes a test or a quiz the result is added to his record. In the history part is possible to review the questions and answers and thus it helps proceed with the preparation accordingly.

Also, PrepKit collects the statistical information about the exam objectives and maps it to your progress, so it is easy to see which areas are required for improvement.


I find the PrepKit software quite useful for SCBCD5.0 exam preparation although there are several things to improve. The tests are well structured and provide close to real exam questions. The educational part of the PrepKit is a little noisy of some information that could be optimized but it still provides quite valuable information while studying the EJBs. Also, the software guides you which part of your knowledge is missing for the certification, which is very useful to know. I would definitely suggest the PrepKit to everyone preparing for the SCBCD5.0 certification exam.


uCertify is offering a discount to you! You can use the discount code given below and get 10% discount on the uCertify PrepKit of your choice. The discount code is:


Wednesday, January 2, 2008

The Closed-Source Software Buy-In

The Case

What makes our stakeholders to take a decision for proprietary software buy-in? Literally, one stakeholder was eager to implement a "brand-new-cool" solution for automating some of the business operations that forced him to hire 3 more employees. So the claim was that if once he have the product installed, and the data integration is done against our core system, then eventually everything will work... That said, we have: the stakeholder X, the software product Y, that should implement function Z. And finally, the software product Y doesn't include its sources in the shipping package.

As you may have already guessed, this software was not working properly after installation and we could not integrate the data model as the software wasn't suitable for some specific business cases.

Let us to take a look to the root of the issue. When the stakeholder was about to take a decision which software to buy, he did not evaluate the software by using the demo version, but instead, some marketing salesmen were visiting the customer and selling the product using PowerPoint slides... (OMG). The stakeholder knew that the product cannot perform some operations, so the required customization was merely ordered.

Next, after the contract was signed, we were testing our data integration procedures with every new version of the product. And, we were receiving the new versions every 4-5 weeks, periodically, with some bugfixes. Nice. After about 2 years (!) of such integration process we've got to know, that by the time of contract signing, there were no customers who succeeded with integrating this product. And, some customization logic were still not working by this time. At the moment the project is almost 3 years old. Lately we received the new version that was claimed to work accordingly to the ordered specification.

The Hi-Tech

The product is actually a J2EE application, running on BEA Weblogic application server, and, even if have no source code available for this application, we can still see that the application is built using EJB 2.1 (despite it is legacy specification already). So the stakeholder made the decision just based on the PowerPoint slides. The software product was not analyzed if it applies up-to-date technologies, or if it is complies to maturity standards.

... blah blah blah... i could continue for nothing :)

The Real Problem

As I see it at the moment, the stakeholder's point of view in this situation is that the integration team is the bottleneck, as we fail to integrate the product.

So my list of questions for this issue is:

  • What makes the stakeholder X believe into some product Y, instead of developing the solution in-house?

  • Why doesn't stakeholder try the product demo before signing a contract?

  • What position should take the integration team in this situation?

From the business process point of view, buying the software product from the 3rd party might be even positive: bringing the know-how in. But! Is your stakeholder so incompetent that it would take n+1 years to complete the project?

Tuesday, January 1, 2008

Am I a good PHP programmer?

I found a recruiting test for PHP programmers today. I have no experience with PHP at all and haven't written a single line of PHP code in my life. So I decided to try, if my Java knowledge will help me with PHP.

The test result says that I'm a good PHP programmer! :)

Disqus for Code Impossible