Friday, 26 April 2013

Developer Diary - Spring/Maven Bug of the Day

So I just stumbled into this trap whilst dealing with some legacy code, thought I share some of the gems I came across...

Did you know that Tomcat 6+ uses the "java.util.logging" logger and not the log4j logger? This means that if you ever want to make sense of messages like "SEVERE: Error listenerStart", you will need to stick a "" file in your resources folder (see this article for more information). Thankfully Tomcat will then give you a better description on the actual underlying problem after this...

Which brought me onto the error message:
java.lang.NoClassDefFoundError: org/springframework/core/env/EnvironmentCapable

Having checked for a consistent spring version and doing much routing around, I realised the spring-core had not been explicitly declared as a dependency in the module I was looking at. Instead one of the other modules it depended on would load spring-core. This module just so happended to be the one I had just removed... Dx

Anywho, it is now declared as an explicit dependency in the pom.xml. I'm not sure if the lesson here is to be more strict with Maven or just to not use Maven all together :P

No comments:

Post a Comment