Home > Engineering > Beware the non-namespaced classpath resource

Beware the non-namespaced classpath resource

We spent too long hunting down a bug in a database method call that consistently returned “null” in our integration environment, but returned the correct value in a development unit test.

Do you see the problem here? Compare these two screenshots. Both screenshots show a look into two different jars on our classpath. The title of this article is a big hint.

jar_two.JPG jar_one.JPG

Two points goes to the first person to explain the problem. (-2 points for any of my teammates that answer first!)

The moral of the story is that namespaces are one heck of a good idea and that we should always be very careful when relying on classpath-based resources.  I’ll write more about the problem after giving others a chance to solve the puzzle.

Categories: Engineering Tags:
  1. February 16th, 2008 at 23:57 | #1

    Let me guess… since each of the JARs has a hibernate.cfg.xml at the top level, it was picking up the first one in the classpath it found. Yup, namespaces can be handy for avoiding such conflicts. :)

  2. February 17th, 2008 at 01:09 | #2

    Exactly right. Two projects by two different teams and there’s my team attempting an integration effort. It took a lot of digging to figure this out, but now we know. I’ll put a notch in the “experience” part of my brain.

  1. No trackbacks yet.

Switch to our mobile site