Archive for April, 2011

Podcasts for Developers

April 29th, 2011

Until I started to travel on a regular basis I haven’t been aware of the value and information that can be found audio podcasts for developers. I thought, “Come on, what can you learn from listening to a radio?”.

Nevertheless, since I had to fulfill my time with something other than staring at empty space (I travel by night) I tried listening to some podcasts and since then I haven’t stopped to follow the ones that I liked the most.

In my opinion (being a Java developer most of the time), Java posse is the best podcast around. The guys behind it are very amusing, have different characters (opinions), and often make a roundups on hot topics where they include more people in discussions. For example, episode #337 they made together with guys from .net rocks which is I guess the best podcast for .net developers.

Apart from Java posse I like listening to grails podcast although they are not as regular with new stuff as Java posse is.

In near future I plan to check some python or ruby podcasts and compare their awesomeness to Java posse.

Try listening to any podcast for developers and you won’t regret. The feeling you’ll probably have is like you have found yourself a good developer friend who is willing to share his personal insights and programming knowledge with you. At least that is how it was in my case.


fun, General, groovy, Java, ruby , , , , ,

My startup ideas list (no it’s not revealed)

April 20th, 2011

I’ve decided to reveal my startup ideas list size (not the actual content which is in Serbian and would take some time to translate).

This is the list I populated in the last 3 years. Whenever I got an idea about something (in 99% it is IT/web/app stuff) that could be interesting to be done but may lead to startup company or something that can be done out of pure altruism I’ve written it to my tadalist. This tadalist helped me to reduce my frustration of not having time to work on “my stuff” and fear of forgetting what I wanted to do.

Today, I looked at this list to pick the best ideas and could easily enlist a few (actually six which are marked with green arrows on image below). Sadly, I’ve only managed to make some progress on only two items (out of 70 something) and even that small progress didn’t happened until recently.

I guess I am a bad executor but I am improving myself.

I wonder how many people have more/less ideas and what is their execution rate. Also, although I am not 18 for more than a decade, what do you think “Do I have potential?”

my startup ideas

my startup ideas


fun, General , ,

Dbunit composite primary keys

April 20th, 2011

Warning: count(): Parameter must be an array or an object that implements Countable in /www/webvol14/yj/kljuhyzt1cwiiug/ on line 76

For some task I was doing I had to make a snapshot of mysql database having only jdbc connection available. I wasn’t able to use mysqldump (remote access) or other backup tools (I wanted to do this as part of my java program – programmatically).

So, I came across which allowed me to backup my database to xml file.

The routine is rather simple (please note the escape parameter setting which is required if (like in my case) author of legacy code you have to use put ‘table’ or some other odd name as a column name ๐Ÿ™‚ :

public void saveDb(OutputStream os) 
   throws DatabaseUnitException, SQLException, IOException {
   IDatabaseConnection connection = new DatabaseConnection(getConnection());
   DatabaseConfig config = connection.getConfig();
      new MySqlDataTypeFactory());
      new MySqlMetadataHandler());
   config.setProperty(DatabaseConfig.PROPERTY_ESCAPE_PATTERN, "`?`");
   IDataSet fullDataSet = connection.createDataSet();
   DefaultTableFilter tableFilter = new DefaultTableFilter();
   IDataSet filteredDataSet = new FilteredDataSet(tableFilter, fullDataSet);
   FlatXmlDataSet.write(filteredDataSet, os);

Then, when I wanted to restore it with:

public void restoreDb() throws Exception {
   IDatabaseConnection connection = new DatabaseConnection(db.getConnection());
   DatabaseConfig config = connection.getConfig();
      new MySqlDataTypeFactory());
      new MySqlMetadataHandler());
   config.setProperty(DatabaseConfig.PROPERTY_ESCAPE_PATTERN, "`?`");
   IDataSet dataSet = new FlatXmlDataSetBuilder().build(new File(fileName));
   DatabaseOperation.DELETE_ALL.execute(connection, dataSet);
   DatabaseOperation.REFRESH.execute(connection, dataSet);

This method wont’t work if you have a table without primary key or oddly defined composite keys. It will throw: org.dbunit.dataset.NoPrimaryKeyException

The solution is to add primary key filter configuration option like this:

config.setProperty(DatabaseConfig.PROPERTY_PRIMARY_KEY_FILTER, new IColumnFilter() {
 Map<String, List<String>> tablePrimaryKeyMap = new HashMap<String, List<String>>();
         Arrays.asList(new String[] { "composite_part1", "composite_part2" }));
       Arrays.asList(new String[] { "other_part1", "other_part2", "other_part3" }));
      // ...
   public boolean accept(String tableName, Column column) {
      if (tablePrimaryKeyMap.containsKey(tableName)) {
         return tablePrimaryKeyMap.get(tableName).contains(column.getColumnName());
      } else {
         // you can add default handling if for example all
         // other table ids are named as 'id'
         return column.getColumnName().equalsIgnoreCase("id");

And that’s it. Yee!


Java, testing , , , ,

Apache CXF Linux Deployment

April 11th, 2011

A short reminder of small issues I had with deploying Apache CXF web service I built on linux server (CentOS in my case):

yum install tomcat5 went really well ๐Ÿ™‚ and then I had to add webapps and manager packages with separate commands.

tomcat5 package depends on jdk-1.4 so in case you haven’t already installed a more recent version of java you’ll get this one.

I used the tutorial from to set up the options for deploying to tomcat using maven and that went well, but jdk-1.4 was causing spring context loader to throw:

SEVERE: Exception sending context initialized event to listener instance of
class org.springframework.web.context.ContextLoaderListener
java.lang.NoClassDefFoundError: org.springframework.core.CollectionFactory
at java.lang.Class.initializeClass(

and the actual error displayed when I tried to access the service from the browser was:

threw exception javax.xml.transform.TransformerFactoryConfigurationError:
Provider org.apache.xalan.processor.TransformerFactoryImpl not foundย  at
javax.xml.transform.TransformerFactory.newInstance(Unknown Source)ย  at

This was solved by installing open-jdk 1.6 devel package with yum, but then another, trickier error appeared:

java.lang.NoClassDefFoundError: org/apache/xml/serializer/OutputPropertiesFactory
at org.apache.xalan.templates.OutputProperties.(
at org.apache.xalan.transformer.TransformerIdentityImpl.(

At several links (here and there) I figured it out that it has something to do with xalan.jar which was unavailable to my service deployed on tomcat. A command:

yum list xerces* xalan* | grep installed

showed that I already had xalan-2.7.1 in my /usr/share/java so I tried with copying it to CATALINA_HOME/common/endorsed but that didn’t fix the problem. I also tried symlinking xalan.jar to that file but that didn’t work either.

In the end, at the link which appeared to be some forum’s archive I found that someone had problems similar to this and was advised revert to xalan-2.6 version. I’ve tried with jar in and it worked.

Yeee “me happy” ๐Ÿ™‚


Java, Links, linux , , ,