Sonar “Close Connection” warning workaround.

Tuesday 2009-10-06

When you use Spring and Ibatis and SQLTemplates, you could have code in your project which looks somewhat like this:

Connection connection = DataSourceUtils.getConnection(getDataSource());
...<do connection stuff here>...
DataSourceUtils.releaseConnection(connection, getDataSource());

Sonar will report that you did not close the connection, while in fact, Spring did that for you. You can not just add a “connection.close()” to the code because the whole point of calling “releaseConnection()” is to have Spring handle all the smart stuff on committing, closing, and returning the connection to the pool if needed.

Read the rest of this entry »


Eclipse 3.4.1, OSX and Java 1.6

Sunday 2008-12-28

Eclipse application icon

I recently downloaded Eclipse 3.4.1 for Mac OSX, and tried starting it using the eclipse.app icon. It did not work, and I noticed a message in /var/log/system.log telling me that the JVM could not be loaded.

Read the rest of this entry »


J-Fall 2008

Thursday 2008-11-13

NLJUG small dukeLast wednesday I was at J-Fall 2008, a fairly large event for Java programmers in the Netherlands. This event is organized by NLJUG. You can read some of my notes on the different sessions in my public evernote.

Read the rest of this entry »


Spring SystemPropertyInitializingBean

Wednesday 2008-07-23

When using POI in any of your projects, and the application you’re building is a web application, you probably have it running on a Windows machine. If not, you know all about the struggle with the “headless mode” environment setting to tell the JVM how to handle graphics rendering.

I always like to keep my applications as clean as possible to the users. The system administrator is also a user of the software (during installation at least). So I wanted the application to set the environment properties itself, In this case, I built a nice little Spring bean to handle this. The solution is so simple, that it is almost a brilliant display of what Spring can solve for you. Suddenly, all these environment setting problems turned into a simple Spring configuration problem. Here’s how:

Read the rest of this entry »


Ibatis 2.2 Ignores XML encoding

Sunday 2008-07-20

At my company, we’re using Ibatis to do operations on Oracle databases. As most of our software is designed to be international, we keep our XML files in UTF-8 encoding. Recently we discovered that Ibatis had some trouble parsing the XML files when we were using diacritics in them. As it turns out, Ibatis 2.2 actually ignores the “UTF-8″ setting in the XML file header altogether.

This was actually reported as an issue at apache’s issue tracker, and fixed in Ibatis release 2.3 and upward. In the meantime, if you can not swich to a new release because of tight deadlines and no time for regression tests, you can set the file.encoding property to UTF-8, because then Ibatis will parse the XML in the correct encoding.


Tomcat, UTF-8 and the RequestDumperValve

Sunday 2008-07-20

A week ago, we encountered a funny problem where our Tapestry 3.0 application seemed to screw up the encoding of form posts. Every time we tried to post a form with diacritics in the input fields, the data got mangled before reaching the application code.

As it turned out, somebody had turned on the RequestDumperValve in the Tomcat configuration file. The request dumper does not only dump the request, but is also kind enough to mangle the data before handing it over to the servlet for further processing:

Read the rest of this entry »


Hacking Your Way Through Codebases

Wednesday 2008-07-02

I found a nice blog post which describes how it is after you leave school and start programming for a real company. You discover that programming is more like 80% reading and 20% coding.

Read the article at the Tired Architect’s blog titled “Hacking Your Way Through Codebases”.


Follow

Get every new post delivered to your Inbox.

Join 34 other followers