Archive for February, 2006

JCL ClassLoader woes

Tuesday, February 28th, 2006

Writing a mojo that would allow me to reuse XFire potential to generate WSDL files without having to fire my web container, I just lost half a day to something I thought would only take 20 min.

The culprit: JCL ClassLoader issues due to XFire using Spring using JCL.

Whatever I tried, Spring would fail either not finding a log4j class or finding 2 JCL jars in the classpath.

I finally solved my issue by:

  • adding a non needed dependency to my plugin (log4j).
  • change the Ant Task I had just written to accept a ClassLoader argument
  • create a class loader that would add the pom dependencies to the plugin ones

This solution is probably not even very robust (what if someone uses commons-logging with another implementing logging mecanism?)

Argg…..

If Spring was to go away from JCL I would probably have a cleaner solution.

CruiseControl 2.4.1 released

Tuesday, February 28th, 2006

Jeffrey just released version 2.4.1 of the popular CruiseControl continuous integration framework. Among the various fixes and improvements, support for maven2 is finally in, an ExecBuilder that would allow to build anything without resorting to using an ant wrapper, a cool WeblogPublisher as well as a couple of important fixes related to configuration changes and notifications.

Enjoy!

Maven 2: poor man’s local repository analyzer

Friday, February 24th, 2006

I often have the need to identify in which package a class is coming from. The Repository Manager Project is supposed to help us with that, but it’s not yet ready. In the mean time, I have been using this simple set of Linux scripts to search my local repository for jars. Of course, that only solves the issue if you already have the jars on your machine…

m2repo

# $0 pattern [filepattern]
# search repository for pattern $1 in jar files (restricted to $2, optional)
pattern="*.jar"
if [ $2 != "" ]; then
  pattern="*$2*.jar"
fi
echo "1: $1"
echo "2: $2"
echo "file pattern $pattern"
find ~/.m2/repository -name "$pattern" | xargs -l1 jarsearch $1

[Note: remove the ‘\’ character before the ” ones. That’s the blog program playing tricks with me]

jarsearch

# search pattern $1 in jar file $2
echo Dealing with $2
jar tvf $2 | grep $1

I use it like that:

# search for a class named FieldPropertySeed in a jar file whose name contains jaxb
$ m2repo FieldPropertySeed jaxb
1: FieldPropertySeed
2: jaxb
file pattern *jaxb*.jar
Dealing with /home/jerome/.m2/repository/org/codehaus/xfire/xfire-jaxb2/1.0-SNAPSHOT/xfire-jaxb2-1.0-SNAPSHOT.jar
Dealing with /home/jerome/.m2/repository/org/codehaus/xfire/xfire-jaxb2/1.0-RC1/xfire-jaxb2-1.0-RC1.jar
Dealing with /home/jerome/.m2/repository/org/codehaus/xfire/xfire-jaxb/1.0-RC1/xfire-jaxb-1.0-RC1.jar
Dealing with /home/jerome/.m2/repository/xfire/jaxb-impl/2.0-ea3/jaxb-impl-2.0-ea3.jar
  3147 Fri Dec 23 13:52:36 CET 2005 com/sun/xml/bind/v2/model/impl/FieldPropertySeed.class
Dealing with /home/jerome/.m2/repository/xfire/jaxb-api/2.0-ea3/jaxb-api-2.0-ea3.jar
Dealing with /home/jerome/.m2/repository/xfire/jaxb-xjc/2.0-ea3/jaxb-xjc-2.0-ea3.jar
Dealing with /home/jerome/.m2/repository/jaxb/jaxb-api/1.0/jaxb-api-1.0.jar
Dealing with /home/jerome/.m2/repository/jaxb/jaxb-impl/1.0.5/jaxb-impl-1.0.5.jar

xfire maven2 plugin

Tuesday, February 21st, 2006

xfire 1.0 is about to be released. If you use maven2, I just published a litte maven2 plugin onto the mojo sandbox.

It only contains wsgen right now and is using the XFire Ant tasks as backend. Check it out and report any issue.

David Baron on character encodings

Sunday, February 12th, 2006

David Baron, of Mozilla fame, made a very good introductory document targeted to web authors describing the need to use character encodings.

Recurring Anti Patterns in software layers

Saturday, February 11th, 2006

COM, CORBA, EJB, Web Services and XPCOM.
The problem is not new. It’s even been known for ages. But every user community of a technology involving interfaces between (possibly remote) components has to go through the same trial and error cycle, finally reaching maturity when good design patterns combined with a little bit of real life experience and good sense compensate for the too fine grained usage that comes out from over-enthusiasm and inexperience of the first adopters.

It’s funny, but it looks like everytime a new technology appears, programmers forget the experience of their fathers. Stand up on the shoulder of giants as they say…

You want a tip? Wait for the next technology, and write an article/book on good design patterns involving that technology. You won’t need to be the best designer ever (although you still need to be good at it), just make sure you have the right writing skills.

Ultimate CruiseControl preconfiguration

Saturday, February 11th, 2006

(Jeffrey Fredrick has en entry on how to trim CruiseControl configuration files using preconfiguration. I wanted to comment there, but either commenting doesn’t work, or there was some moderation to perform before the comment would show up. So I reproduce it here).

Hi Jeffrey, I am happy that you like the feature!

Another nice usage is the ability to rename the plugin. Useful if you have different project types, e.g. if you are in the middle of a migration, or if you have 2 different project groups but consolidate the CI on one server. I already had written about it here.

E.g.

<plugin name=''antproject''>
  ... project with ant builder(s) ...
</plugin>
<plugin name=''mavenproject''>
  ... project with maven builder(s) ...
</plugin>

<antproject name=''ant1''/>
<antproject name=''ant2'' />
<mavenproject name=''maven1'' />
<mavenproject name=''maven2'' />
...

You could do the same for cvs/svn, etc…

The URL to the official documentation:
http://cruisecontrol.sourceforge.net/main/plugins.html#preconfiguration

Introduction a l’informatique / Introduction to IT

Friday, February 10th, 2006

French

J’ai fait une petite petite introduction a l’informatique (materiel, logiciel, reseaux, securite et logiciels libres) au centre culturel francais d’Oslo cette semaine. La presentation est sous license Creative Commons. N’hesitez pas a ameliorer/reutiliser. C’est en Francais…

Cherchez le 08th of February 2006, et suivez les liens….

English

I made a small introduction to IT (hardware, software, networks, security and FOSS) at the French cultural center this week. I used a Creative Commons license. Feel free to improve/reuse. It’s in French…

Search for 08th of February 2006, then follow the links….

JavaPolis Summary at the Oslo JUG

Friday, February 10th, 2006

Last month, the Oslo, Norway Java User Group made a summary of the JavaPolis 2005 conference. We shared the report into 4. I now also have uploaded my talks page.

a Michelin star for une Cuisine en Ville & Philippe Lagraula

Friday, February 3rd, 2006

<offtopic>
After being recognized by GaultMillau last year, Une Cuisine en Ville, a restaurant in Dax, France, got his first macaron.

Congratulations to Philippe Lagraula, 26, who started his restaurant only a year ago.

Philippe, let me tell you that I really like your food and I am very proud that you chose my brother to help you in the kitchen :)

If you travel to the South West of France, pay them a visit. Be sure to book some days in advance!
</offtopic>

XML Performance in .Net/Java/Mono, now for Linux on JDK6.0

Friday, February 3rd, 2006

Really interesting benchmark comparing XML performance on various platforms (.Net 1.1/2.0, Mono, Java 32bits/64bits). The Mono guys apparently have their libraries working, althought not yet with a huge performance (but they are working on it).

Now the Java performance was far from .Net 2.0. So I decided to have a look at it. One thing that I would have liked is a test including JDK 6.0 on Linux.

CruiseControl 2.4 released

Wednesday, February 1st, 2006

In case you’ve not seen it, CruiseControl 2.4.0 has been released some days ago. I haven’t helped much this release feature wise, due to other projects taking too much of my time :) but I will come back to that hopefully end of Q1 2006!

Thanks to Jeffrey Paul and the others for their good work.

a critical look at Maven2

Wednesday, February 1st, 2006

Introduction

I started using m2 extensively in the past 3 months in various projects. During that time, the m2 core came to be released, then the plugins. In the course of this experimentation/work I encountered various successes and failures. On a particular project with a client (migration of a 150000 lines of code project built from maven/ant to maven2) we had a particular hard time.

First m2 was missing some features for our build, in particular to build webstart applications. The functionality to do that (sign the jars, package the JNLP application, …) was missing in m2, and m2/ant integration wasn’t an option. So I’ve had to implement it. Then I’ve had to slightly tweak my maven build, which was relying too much on various local tweaks in maven.xml files. Finally I’ve had to change somehow the way we produce our final artifact for the various customers. Customization now happens at a different phase of the overall building process, which matches better our work model. m2 profiles were used to make this work.

Doing the migration I lost many hours due to various m2 issues. All in all I think I encountered around 15 issues that directly affected my productivity. I’ve fixed many of those, some are still unpatched and working with m2 today still requires to build my own patched version of m2, and upgrade a couple of times per week. In terms of time, my estimate of the time it would take to write the Webstart plugin was roughtly correct, but I spent much more time trying to work-around m2 bugs and/or fixing it.

Potential Improvements

I know that some people are going to not be particularly happy by this section. But someone has to say it :)

Here follows a list of issues and potential recommendations:

  • bugs, regressions and maturity. Today that’s the main issue to me. As soon as you start using maven/pluggins in ways people haven’t used them, you walk on eggs. In particular, I’ve had many plugins fail when used within the reactor. To prevent these issues, a developer methodology to test plugins should probably be defined to help plugin writers avoid common mistakes.
  • debugging the core can be a daunting task. Writing unit tests for it is even harder. Even Jason says it.
  • in case of a failure, m2 tells you to rerun the build with the -e option to get a stack trace. That’s completely counter productive. Do not ask me to rerun my full build with -e enabled. Just keep track of the failure somehow, and display it for me.
  • XML verbosity. I am sort of tired to write very verbose XML files. First spring now maven2. Yack. Example: try to manually change the version of your multi-project. If you don’t use the maven release plugin (which is known to have some issues), you will have to change all your poms. Why can’t this be in one place? This is linked to the maven way of defining poms, but you wonder if KISS just went away. I don’t have a better solution to propose for the general XML verbosity issue though, apart from designing very carefully the maven’s core. Maybe that will be partially addressed in 2.1.
  • better installation. When you rebuild and reinstall some of the core m2 modules, you will sometimes need to copy them into your M2_HOME/lib directory. That was maybe fixed since 2.0?
  • documentation. Although very good, some cases are not covered enough. In particular, the model document is sometimes not easy to browse. I wish it was formatted like the CruiseControl config file was. The documentation (guides) is also perhaps not well structured to my taste, and lacking in some areas, probably because it is automatically generated.
  • similarly m2 introduces many new terms & concepts. A m2 dictionnary would help (note: the m2 book is on its way, so that may come in the form of its index)
  • plugins style consistency: m2 developers should perhaps setup a structure to review initial design proposals for externaly hosted plugins to make sure they are developed to fit correctly within the m2 model and philosophy.
  • for plugin developers, I spent quite some time trying to find out which dependencies I needed to add in my pom, and which version. When I didn’t have my IDE opened on the maven project itself, I spent most of my time doing locate ClassName to find out the module the class was pertaining to then check in the logs whether the required pom was there or whether it had the right version. That worked because I had the whole m2 source on my machine, as well as plexus source, doxia source… We maybe need a sort of versioned jarhoo for maven 2 related projects?
  • I think that it’s very easy to not find out about particular maven issues if you have a locally deployed dependency and a broken maven that incorrectly searches for the dependency. For similar reasons, I wonder if m2 developers tend to have an environment that doesn’t let them find out the issues user face (in particular dependencies issues). I may be wrong there, so I won’t extrapolate too much. Now I wonder how this issues will affect Continuous Integration setups. For the moment I recommend using a different repository for each independent project your are using. You should try to avoid any side effect your local repository may introduce.
  • upgrading m2 without cleaning your repository can let you in a dependency mess (in particular if you had a snapshot version installed). Cleaning your full repository forces you to manually reinstall all some artifacts (jdbc, jta, …). Be use to set up a corporate repository soon enough.
  • slow slow slow ibiblio. Anyway, you shouldn’t completely depend on the Internet. Use a mirror and even better maven proxy.
  • maven now has many plugins which are small projects themselves. These projects have their own release cycle. That’s a big departure from the way traditional open source frameworks have been released (ant, cruisecontrol, etc…). There are obvisouly benefits (easy to push a fix to the users) but that creates other issues. You may introduce breakage if your poms haven’t been correctly specified and a regression is introduced. Similarly it’s up to the bug reporters to make sure their issues are taken into account. Sometimes one will have to poll the developer list and notify the developers that a particular issue is to be included in the release. That will go hopefully away when the code will mature. Still one can see the typical dependency issues that have plagued Linux distributions for years.

Good parts of m2

Not all is that bad!

  • the m2 developpers have been very quick at empowering me. They gave me committing access to the mojo-sandbox where I’ve been able to upload various plugins required for me to work that could be useful to the community. I believe this to be a very good move from the official developers of the m2 related toolset. The m2 community is indeed very active, and allowing people to be gradually involved in the project can only benefit them. I am also pretty satisfied with mojo community. I’ve received a lot of enhancements in the form of patches and ideas that now will soon make some of the plugins really production ready
  • I find the standard lifecycle and directory layout a breeze
  • mailing list/IRC support: mostly good, even if it tends to be less efficient when a people are busy (preparing a release, writing a book…) :)
  • the quality of the project (and documentation) is increasing. The trunk seems to be broken less than before, and the developers are willing to make maven 2 a better product.

Conclusion

m2 shows great promises. Its current state is not completely ready for production (at least not for all kinds of projects), altought it is getting closer and closer. Depending on how you will use m2, you may encounter many many small irritating bits, or slightly broken features there and there. When trying to migrate a small and relatively heterogeneous project, you might spend too many resources fixing internal issues or adding missing functionality through plugins. On the other side, the bigger your project, the more homogeneous it might be. The economy of scale will reduce these migration costs. With regard to starting a new project today, I definitively advice you to consider using m2, especially if you don’t need fancy features. E.g. if your project is a back-end sort of things, like combining layers of jars together into a single project that do not require many customizations, m2 is definitively a tool to look at for your infrastructure. As with other types of projects, in particular big J2EE projects, work is being done to produce sets of guidelines that should make your life easier.

The plugins I looked at were of differing quality but most were good. For developers, if you want to develop a plugin, be sure to spend time understanding the concept of life cycle. I definitively lost some time here jumping too early into the code (for my defense, the documentation was shallower when I started). Spend also time understanding the way dependencies and release mecanism work.

Many people are coming to maven because of dependency management. If you just need dependency management, maybe you can get away by using the maven2 ant tasks. Even with those, dependencies issues are problems that Linux distributions have had since their inception and that won’t disappear tomorrow. If you choose to use transitive dependencies, you just trade one problem for another one, hopefully smaller. But remember, dependency management is only as good as your poms and release process can be!

All in all, I believe m2 is going to rock, but it will take some time, because it changes the way we do things. M2 brings in a long awaited set of features really useful for managing big projects. Its philosophy can sometimes feel to be in your way to gets things done when a particular feature is missing or an issue affects your setup, but I think it pays a lot on the long run to follow these somewhat enforced guidelines. And if you use maven/m2 just remember one thing: don’t try to fight it.

I will give it a 3.5 stars out of 5, but I believe it will be worth 4 or 4.5 within the year.