Delete all Eclipse project related meta information via shell

Today I was fighting some really annoying behaviour of Eclipse in combination with refactored multi module maven projects.

Whenever I tried to import the projects, I recieved the error

An internal error occurred during: "Updating Maven Project". java.lang.NullPointerException

I tried to solve the problem by removing my eclipse projects and cleaning all eclipse related files, but that didn’t work. For some reason mvn eclipse:clean refused to delete my files. Thus I had to find a way to recursively delete all eclipse related information from my project. So here it is:

find . -name .classpath -exec rm -rf {} \;

find . -name .project -exec rm -rf {} \;

find . -type d -name .settings -exec rm -rf {} \;


Using local GIT to access remote SVN repository

git is nice. Very nice. But as we are still using SVN for many projects, using git is not always possible. Or, is it?!

Luckily, git comes with very nice support for using it in combination with an SVN remote repository. By doing so, you can clone any SVN remote repository into a local git repository, create local branches, local commits, local reverts, etc… and finally push everything back to SVN.

Creating the initial clone
git svn clone -T trunk -t tags -b branches -A authors.txt {your_SVN_repository_url} {your_local_git_repsoitory_name}.GIT

Example: git svn clone -T trunk -t tags -b branches -A authors.txt myrepo.GIT

Note: You need to have an authors.txt file in your local directory from where you execute the command. The file should contain all contributers from the SVN repository. On you can find a command to create such a file.

Get latest changes from SVN trunk and pull them into master
git checkout master
git svn rebase

Commit local changes back to SVN
Make sure to apply a git svn rebase first! (See above)

git checkout master
git svn dcommit

Get rid of “unmappable character for encoding Cp1252” once and for all

Nowadays, many open source as well as commercially developed projects contain code that is UTF-8 encoded. More general it is very unlikely that you checkout some code from GIT, SVN or [insert arbitrary abbreviation here] that is actually encoded with Windows’ crappy default encoding. (In case of my western European system, that encoding would be Cp1252).

So, how many times have you seen the above error when compiling some Java code on a windows machine? And how many times have you wondered if there is a solution to set the file encoding in a global, system wide manner? Well, fortunately, there is a way to do that!

A quite simple procedure to globally set the file encoding for all JVMs is given in the answer by erickson in this stackoverflow question. All you need to do, is to specify a envirnoment variable called JAVA_TOOL_OPTIONS. If you set this variable to -Dfile.encoding=UTF8, everytime a JVM is started, it will pick up this information.

Obviously, you are able set other JVM parameters via JAVA_TOOL_OPTIONS as well. See the JVM documentation for more details. If you are interested in further details about character encodings in Java, check out this excellent article.

Database Reverse Engineering with Spring Roo 1.2

Reverse engineering an existing database into a new application seems to be one of the most important features in rapid application development. Having the right tools at hand can give you a major boost when rewriting an application on top of an existing database.

Spring Roo hasn’t had support for Database Reverse Engineering (DBRE) when its first major version was released. Not surprisingly, adding DBRE support had been the most requested feature for subsequent versions. In Roo 1.1 full support for incremental DBRE was added and since then it has been constantly improved. It is fully documented and pretty much straight forward to use.

According to my WordPress Stats, my old post about DBRE in Roo is still the second most visited on my blog. As it became more than obsolete, I thought it might be time to clear things up and point you guys to the new DBRS features in Spring Roo 1.1.x and 1.2.x

So if you are interested in Roo and/or DBRE, make sure to check out the latest developments in this area.

Using the Power of Eclipse Marketplace

Even though I have been developing with Eclipse for about 8 years now, I never found a good way to manage my favorite plugins in a way that works for me. During university and professional work I often had to and still have to install new instances of Eclipse on my computers. And everytime I struggle in finding and installing my favorite plugins.

Just recently, the Eclipse Foundation has launched the Eclipse Marketplace. Besides being a central place to search for eclipse plugins it has some additional benefits. Advanced searching, tagging, social linking and one-click plugin installation are just some of those. But to me the absolute killer feature is creating your personal list of favorite plugins. Not only does it become obsolete to search for all the individual plugins you like, additionally you can install them all together from just one update site url. The screenshot below indicates how you might access your personal update site url, once you have set up your favorites.

Once you have a list of your personal favorites, you can also share that list with friends, co-workers or the general public. Just like I do. So, go out there and sign up at Eclipse Marketplace. It saved me a lot of time and pain in setting up my eclipse installations, and so it may help you.

Missing Snapshot Dependency in Spring Roo Project

Today I ran into an error while trying to create a plain new Spring Roo project based on the latest nightly snapshot build of Roo.

[ERROR] Failed to execute goal on project cassandra: Could not resolve
dependencies for project cassandra:cassandra:jar:0.1.0.BUILD-SNAPSHOT:
Failure to find org.springframework.roo:org.springframework.roo.annotations:
jar:1.2.0.BUILD-SNAPSHOT in was
cached in the local repository, resolution will not be reattempted until the
update interval of spring-maven-release has elapsed or updates are forced

The solution to the problem is quite easy. Just intsall the org.springframework.roo.annotations-1.2.0.BUILD-SNAPSHOT.jar into your local maven repositroy (or alternatively your company’s repository server). The file itself can be found in the unpacked roo installation folder under spring-roo-1.2.0.BUILD-SNAPSHOT/annotations. To install it into your local repository, execute:

mvn install:install-file -DgroupId=org.springframework.roo
-DartifactId=org.springframework.roo.annotations -Dversion=1.2.0.BUILD-SNAPSHOT
-Dpackaging=jar -Dfile=org.springframework.roo.annotations-1.2.0.BUILD-SNAPSHOT.jar

Maven 3 Site Plugin – How To

Creating various helpful reports in a Maven based project is quite easy and straight forward. Such reports vary from simple javadoc to dependency reports and code coverage analysis and having them can be a major advantage during development. In the following post, I present an understandable how-to of generating these reports.


Site and report generation is not a base feature of Maven (anymore [see footnote below]) , instead there is a plugin that is responsible for this tasks. The site plugin can be configured in the plugins section of a pom.xml. The configuration itself can contain several report plugins. The following snippet configures the site plugin and adds a number of useful report plugins to it. Simply copy this configuration to your personal pom.xml and adopt any parameters to your needs. Make sure to remove or replace the configuration file location within the maven-checkstyle-plugin.

          <!-- Adopt config location to your needs, or remove configuration entry completly to use default version.
        <!-- Usually findbugs needs a lot of memory, change these values if needed. -->
          <!-- Change minimum priority to see more or less messages -->


Report generation

Once, your configuration is set up, you can trigger a report generation with the command mvn site. Depending on the reports used, this may take a while. The final reports will be placed within the target folder. Just open target/site/index.html and you should see something similar to the following screenshot. Click on one of the two red-circled links to expand the report sections. Enjoy reading through the reports and improving your code.

Example Page - Maven Site Plugin

Note: With the introduction of Maven 3, there have been changes in the area of site and report generation, thus the shown pom.xml snippet does only work for Maven 3.0 or later.

10 Typical Problems in Enterprise Java Applications by Eberhard Wolff

Just had a look through some nice slides done by Eberhard Wolff (there is also a video in German, but I haven’t had the time to watch it yet). As Eberhard mentioned on his blog post, depending on the audience many people seem to be already aware of those typical problems. Then on the other hand I have seen sooo many projects and source code violating common sense and introducing exactly those common mistakes…

My personal opinion; especially the use of AOP and comprehensive testing should get more emphasize in businesses and education. Not sure if people will ever learn to write (Java) code that is capable of handling multi threading and transactions appropriately. But some of the other issues can defiantly be tackled by better education of software developers.

Anyways, a quite nice presentation, and even if you aware of most of these problems, getting them back to your brain might help during your next project. Thanks Eberhard!

If your maven site build is too slow

Today I stumbled upon a very slow site generation with mvn site. To be honest I didn’t really bother about having a look into tho log messages at first. But these messages should have made me conscious that something was going wrong:

[ERROR] Unable to determine if resource batik:batik-util:jar:1.6-1:compile exists in
[ERROR] Unable to determine if resource exists in

The message is quite clear, one of the report plugins (namely the dependency report plugin) tries to determine if resources are located within a given repository. If that repository doesn’t exist anyomore or is just terribly slow, your site build will be as well.

Thanks to Andy I figured out that I can easily swith that part off by providing an extra parameter to mvn site -Ddependency.locations.enabled=false.

Enjoy your faster site build, and do check your repository configurations regualary!

Faster logging with SLF4J

Logging in Java has a long and obscure history. There are numerous APIs for logging, and there is for sure no answer which one is the best. Today, I started a project from scratch, which gave me the opportunity to try out SLF4J (Simple Logging Facede 4 Java). In most of my projects I have been using  Log4J so far. The switch was rather simple, anyways I would like to write down the most important steps here.


  • Log4J was initially created by Ceki Gülcü. After Log4J Ceki created SLF4J, so I guess he put everything he learned from Log4J into SLF4J.
  • SLF4J provides a nice way of creating short and easy to read logging statements in the code, that have only minor resource consumption if logging is turned off.
  • Some commonly used open-source projects use SLF4J compared with some of its provider bridges, in seldom cases this might struggle using the bridged logging APIs.
  • Last but not least: Why not? As previously mentioned, there is no best solution for logging, so why not trying alternatives.

How does it work

As the name suggests SLF4J is a logging facade that needs an actual logging implementation to be able to log anything at all. All the widespread logging solutions can be used by SLF4J. So you might use Log4J or JCL or even the Simple Implementation to do logging with SLF4J. In any case you will use the same API calls in your code (thus facade in the name).

Get the JARs

If you configure your JARs by copying them into some lib folder (I hope nobody is actually doing that any longer!), just go to their web page and download the latest versions of slf4j-api and the slf4j-{your favorite provide}. Don’t forget to put the JAR of your provider into the lib folder as well.

If you use maven or ivy, here is the sample configuration for SLF4J backed by Log4J. Please note, that the provider JAR will be automatically retrieved, so do not put it into your maven dependencies.


Let’s log

Logging with SLF4J is pretty straight forward. Just have a look at the example below. The second logging statement shows how the API should be used to avoid to String conversion for large objects if logging is turned off (or the level is lower). Check the SLF4J FAQ for further details on performance of (non) logging. If you are wondering if you should declare your logger as a static or instance variable, make sure to look at that consideration.

final static Logger logger = LoggerFactory.getLogger(Slf4jTest.class);

public void someMethod(HeavyObject object) {
    logger.debug("This is a simple debug message");
    logger.debug("HeavyObject is {}", object);