Showing posts from August, 2010

Is Java getting more and more complex

Recently I read an article in Artima, titled "Have Generics Killed Java?". This article is not the first one to complain about the complexities introduced into Java due to Generics. I used to a C++ programmer for around 6 years and been a big fan of the language. When I switched to using Java, during the pre-Generics era, I simply loved the simplicity and lucidness of Java. After reading the section on Generics in Effective Java, and having learnt the IFs and BUTs of the Generics, I realized how many things one has to remember to make effective use of Generics.

I rememberd an answer given by Bjarne Stroustrup, the creator of C++, a few years before the introduction of Generics. The gist if his answer was that every language commercially successful and used in large scale follows exactly the same path C++ and (now) Java is following. That is to start simple and eventually getting more and more complex.

After reading the FAQ for C++0X and some of the modules in Boost library, …

FEST libraries - a useful set of tools for testing

I came across an article in that talked about the FEST libraries. I felt I should have known about the FEST libraries a earlier. They are pretty powerful in terms of expressing test cases in a human readable form. In FEST site itself I found a link to internal DSLs in Java which was quite an interesting reading.

Eclipse Helios JEE and Tomcat issue

I installed the latest Eclipse Helios JEE package. Every time when I try to start my Tomcat instance, I started getting 100% CPU and an non-responsive Eclipse. I figured out that this was an issue with the WTP that comes by default with the Eclipse package (which I think is 3.2.0) and this issue was fixed with WTP version 3.2.1. If you try to update this package by using "Help->Check For Updates" it won't update. So here is how you can update:
Go to "Help->Install New Software".In the "Work with:" input box, give the URL "".Wait for all the package information to be downloaded and select "Web Tools Platform (WTP) 3.2.1" option. If you are planning to use any other package, you can select them. But make sure you select the ones from 3.2.1 version distribution.Click on Next and follow the prompt to complete installation. If you restart Eclipse, you should be fine. You should…

Cobertura and Spring auto proxying

If you are using Cobertrua to get coverage reports, you may run into the error message shown below (lines folded for clarity):
Caused by: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'myBean' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed;
nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type
'$Proxy28 implementing net.sourceforge.cobertura.coveragedata.HasBeenInstrumented, org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised' to required type 'com.mydomain.MyDao' for property 'myDao';
nested exception is java.lang.IllegalStateException: Cannot convert value of type
[$Proxy28 implementing net.sourceforge.cobertura.coveragedata.HasBeenInstrumented, org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [com.mydomain.MyDao]
for prope…

Bean properties printer - a useful debugging tool

There are many instances when I wanted to just log the properties of a given object (most of the time its a bean). This will be useful in two ways: 1) learn about the concrete type of the object 2) serves as a good learning aid to understand what are all the properties that can be get/set in that object. Of course, if you have the documentation and the source code for the class in question, that would be the ultimate aid.

Nevertheless, the following piece of code would be useful to print the properties of the given object/bean, using the getter methods that are available in the object.
    public static void printProperties(String msg, Object o) {
        String className = o.getClass().getName();
        if(msg != null && msg.length() > 0)
  "{} (type {})", msg, className);
        Method[] methods = o.getClass().getMethods();
        for(Method m:methods) {
            if(m.getName().startsWith("get") && m.getParameterTypes().len…