Archive for the ‘java’ Category

The UnknownHostException and A Not-so-obvious Cause

Monday, June 9th, 2008

The past week has turned out to be the week of “all sorts of weird problems” for me. One of the issues I ran into was that, in a new Ubuntu installation, maven fails to download artifacts from the repository server. After some arm-twisting with maven (people really should start logging the actually exception instead of just printing “unable to download artifact…”), I was able to pinpoint the underlying problem to be an UnknownHostException from trying to resolve the repository server. The strangeness of the situation is, I can access the repo and download the same artifact with firefox, wget, or anything non-java. I can also resolve the repo server name just fine with nslookup. more…

Why does the GWT compiler require an X server and how to work around it

Monday, May 12th, 2008

Got this error today when trying to build our little GWT application in linux: more…

Ivy 2 beta 2 Adds Maven Metadata Support

Tuesday, March 18th, 2008

Ivy 2.0 beta 2 adds an interesting useMavenMetaData switch to its ibiblio resolver. When it’s on (the default actually), Ivy will try and use the maven-metadata.xml for listing the versions available, and for dynamic dependency resolution. This is interesting to me because it makes it a lot easier to run our builds against a proxy repository server like Maven Proxy or Archiva.

Until beta 2, Ivy finds out about the available versions of a module by parsing the directory listing HTML from Ibiblio’s Apache server. That doesn’t work when there is a proxy server sitting in between, because a) the proxy server doesn’t usually proxy directory listing requests, and/or b) the proxy server renders the directory listing in different HTML. Switching to using the structured maven meta data completely eliminated this mess.

Of course, using the maven-metadata.xml files from the official ibiblio repository will subject us to some new hazard - some modules have out-of-date maven-metadata.xml. For instance, by its maven-metadata.xml, the latest version of Hibernate would still be 3.2.0.cr1.

One of those maven proxy servers turns out to be a perfect solution to this problem - we can use them now, remember? :) In my case, I run an Archiva server proxying the official maven 2 repository. Whenever I run into a bad metadata file, I simply request the missing version through Archiva, and it will fetch it and update the metadata file. For example, in the hibernate case, I would just open up Firefox and try to download http://archiva-server/repository/internal/org/hibernate/hibernate/3.2.6.ga/hibernate-3.2.6.ga.jar. That only needs to be done once, and afterwards Archiva would have updated its local version of the maven-metadata.xml properly.

Could Java 7 Please Add A Subpackage Access Modifier?

Sunday, January 6th, 2008

As we all know, the package hierarchy in Java is a rather superficial one. Package com.foo.pack.sub means nothing special to package com.foo.pack - no more special than com.bar.whatever. It’s something that’s seemingly trivial, but really has been discouraging proper organization of classes and more careful design practices. more…

Spring 2.5’s Unintrusive Annotation-based Configuration

Wednesday, November 14th, 2007

Annotation-based configuration isn’t new, but Spring 2.5 adds an interesting twist to it by making it possible to use annotations for wiring, yet without being explicitly tied to any Spring classes. more…

Log4j 1.2.15: What’s With All These Dependencies?

Wednesday, September 19th, 2007

I may not necessarily agree with Weiqi Gao’s opinion that Log4j Must Die, but I have to admit that I really think the new mandatory dependencies added by log4j 1.2.15 are going over the board. To add insult to injury, some of those dependencies - namely com.sun.jdmk.jmxtools and com.sun.jmx.jmxri - aren’t actually available in any public repository due to license reasons. more…

Checked Exceptions and Alternate Business Flows

Tuesday, July 17th, 2007

As I have always had problems with Java’s checked exceptions, I had a little debate with Debasish in the comments section of his recent blog post regarding exceptions in DDD. Over there, I concluded my case with: more…

Yet Another Maze Solver: guess I have too much time on hands

Monday, June 18th, 2007

Here goes my version of the maze solver program to the Excellent Interview Question Shane Bell wrote about. My solution follows the classic “always keep your left hand on a wall” idea. It doesn’t guarantee to find the best route, but then it being non-recursive doesn’t blow up the stack with a large maze, and it at least eliminates all the loops. :)

The self-calling limitation in Spring-AOP and one unintrusive solution

Tuesday, May 29th, 2007

Spring-AOP is implemented by creating proxies decorating the target bean. One typical gotcha from using these proxies, for instance, in declarative transaction management, is the proxy can’t intercept a call made from one method to another on the same target object (typically a service bean), even though both methods are supposed to be wrapped by the proxy. more…

Ivy has lots of potential

Monday, April 9th, 2007

Having recently been severely frustrated by that other ambitious Apache project that aims at “making the build process easy”, and “providing guidelines for best practices development”, etc. - OK, who am I kidding? Yes, I’m referring to maven 2. :-) - I turned my eyes to Ivy, and, after a couple of week of using it, found myself comfortable enough to write this to recommend Ivy as an indispensable part in any serious Ant-based build tools arsenal. more…