Failed to load ApplicationContext...

Last Update: 13.03.2018. By Jens in Developers Life | Learning | Newsletter

That’s the most common error when starting with Spring. Most of the time, it is an error made by us and Spring complains rightly. Sometimes, however, it is not one simple, stupid error caused by us. Reader Mark did have one of those rare exceptions last week.

The exception he got, indicated that his Spring Data repository could not be found. Strange, indeed. A bit deeper in the stack trace, it complained there is no entity manager found.

The cause f this mess?

A failed download of a maven dependency. In his case, maven did not download the hibernate version correctly and messed up the jar file locally. This can happen sometimes, and usually, it makes it ugly appearance with a NoClassDefFoundException and is so easy to spot. He and I knew both this behavior. Yet, it was sneakier this time, no NoClassDefFoundException and none of us suspected it at first.

So, when you experience strange behavior, delete parts or all of your local maven repository (it’s inside the .m2 folder in your home directory) even when it means redownloading the whole internet…