Hello all StackOverflowers,
We recently had a problem with our Java-setup at my company where we had cleaned up some dependencies and we thought all was well because it still compiled. However, we found out that dependencies cached in the .m2 repository caused IntelliJ and Maven to believe we still had the missing dependency. This happened both on our local machines and on the production setup.
The problem manifested itself as a completely silent ClassNotFoundException. Nothing was logged and we had to debug through the application line by line to find the exact place where it happened.
It was not wrapped in a try-catch that would throw the exception away, it just silently failed the method that was called in a loop and went on to the next iteration.
Already, this is a mystery to me as to how it can happen.
To be more specific, it was the org.apache.commons commons-lang3 3.9 dependency that was missing, and it failed on this particular code line
if (SystemUtils.IS_OS_LINUX) {
if the dependency was NOT cached, but succeeded otherwise.
We did try deleting the .m2 cache but the commons-lang3 is a transitive dependency, so it gets downloaded anyway when building.
In my opinion it should not be possible to compile the project with missing dependencies in the POM, even if they are cached. It should result in a compile-time error.
Is there a way to achieve this?