The risks of funny t-shirts

Here in the company I’m currently working as contractor we usually
play soccer once a week. This week I took my t-shirt with the
inscription “Spanish SEX instructor. First lesson free” (sex in very
big letters). So I put it on in the restrooms of the company,
out of the office, and called the elevator. The surprise was when going
out of the elevator was the CEO of the company, but luckily with my
fast reflexes I turned and was able to hide the message. uffff.

That remembers me other great conversations performed by me or coworkers like:

After the buying of the company I was working for:

  • what do you guys do?
  • we’re contractors, and you, are you in sales team?
  • no, I’m the CEO of xxx (the company that just bought ours)

In the elevator

  • what do you guys do?
  • we are in the xxx project
  • cool, how is it going?
  • it’s going ok (here I paid the price of my not so good english)
  • only ok! here in this company we expect the best!!
  • and what do you do? are you in marketing team?
  • no, I’m the CEO

Maven tips and Tricks: Perforce (round 2)

In relation to my last post about maven and Perforce
this is a better solution that will work with both maven 1.0.x and 1.1.
The previous one doesn’t work under maven 1.1 because the bundled ant
version was updated to 1.6, that doesn’t include the optional perforce

This time you’d need:

  • oro and ant-apache-oro as a dependency in your project.xml.
            <!-- you don't need the root classloader if
                 only running under maven 1.1 -->
  • The actual goal in maven.xml
        <!-- perforce -->
        <goal name="p4sync">
                 you need Perforce command line client and maybe specify
                 P4CLIENT and P4PASSWD environment variables
            <ant:taskdef name="p4sync"
            <p4sync view="//depot/whatever/..." />

Another option to avoid defining each one of the tasks is creating a properties file in the classpath and load it with

        <ant:taskdef resource="com.whatever.PerforceTasks"

And the contents of the properties file is

        # Perforce tasks available

Note that you can’t use the properties file bundled with ant because it includes all optional tasks, wich would force you to include all ant-*.jar files in the classpath.

Maven tips and Tricks: running a subset of tests

So, you wanna run only some of your tests because they take too
long? check this as a sample to avoid running dao tests (provided that
you use some naming convention, as calling them *Dao*Test):

    <!-- test configurations -->
    <goal name="test:notdao">
        <j:set var="testmatchpattern" value="**/*Test.*"/>
        <j:set var="testnotmatchpattern" value="**/Abstract*,**/*Dao*Test.*"/>
        <attainGoal name="test:match"/>

The only drawback is that you need the latest maven test plugin (1.7). You can just add this dependency to your project.xml.


Managing your clustered application with jManage

One of the drawbacks of JMX is the lack of cluster support, you have
to invoke the operation in each one of the servers. The solution? use a
JMX client that does that for you, as jManage.
You setup the servers as in any other administration console and then
you can group them in clusters, allowing you to see the value of the
properties in each one of the servers in the cluster and invoke operations
in all of them getting the results of each server in a single page.

Using jManage with JBoss 4

Download jManage version 0.5.3.

Go to jmanage-0.5.3/modules/jboss and copy there the following jars from jboss installation.

  • jboss-4.0.2/client/jbossall-client.jar
  • jboss-4.0.2/lib/jboss-jmx.jar

Start JBoss servers with the java option  -Djava.rmi.server.hostname=hostname (you can set JAVA_OPTS environment variable)

Run jManage with jmanage-0.5.3/bin/, you’ll be asked for a password (123456 by default). Then you can login at http://localhost:9090 with username/password admin/123456

Hibernate 3.0.5 statistics + TreeCache bugs

When working at a client site we decided to enable Hibernate
statistics, so we can access all this information about cache
hits/misses, transactions, entities,… and all kind of cool stuff
through a JMX interface at runtime, allowing runtime configuration
changes and monitoring.

But seems that not many people is using this feature, because we
got the frustrating NullPointerException. After debugging a bit through
the Hibernate sources (if you have ever tried you know that it’s a PITA) I found the errors, same exception in two places,
and told JBoss support (the client was paying for it). Anyway I fixed them
locally while they fixed them in CVS, see the cvs diff or the JIRA issue. This bugs are present in hibernate 3.0.5 when using TreeCache.

Now we can get a lot of useful information at runtime, through a JMX console, I really like jManage,
mostly due to it’s cluster support, but you’ll need some tricks to make
it run with JBoss 4, that I’ll post in a separate entry.

dbUnit, useful more than just for unit tests

I really like dbUnit for unit tests, but I like it more for other
tasks, as exporting data from the database in xml or Excel formats with
a few lines of code and without bothering about writing xml tags or
interacting with POI to write Excel cells.

instance the next code can be used to export the result of a query into
an Excel file.

public class Report {

    private DataSource dataSource;

    public void exportData() throws Exception {

        IDatabaseConnection connection = new DatabaseConnection(dataSource

        try {

            // partial database export
            QueryDataSet partialDataSet = new QueryDataSet(connection);

            String query =
                    "SELECT a, b FROM t WHERE a = 'whatever'");

            partialDataSet.addTable("Report", query);
            XlsDataSet.write(partialDataSet, new FileOutputStream(

        } finally {