Compiler error "archive for required library could not be read" - Spring Tool Suite

75

I am starting to configure my development environment and I am using Spring Tool Suite 2.8.1 along with m2E 1.01.

As far as I can tell, since this is a Maven Project (my first), my Maven POM is dictating (along with m2E smarts) my project build configuration and dependencies.

What I would like to know is why my IDE is displaying Java Build Problems that read "Archive required for library library/path/somejar.jar cannot be read or is not a valid zip file" when I can see the jars in my .m2 repository?

All the errors pertained to commons-logging:1.1.1 which I excluded in my parent-pom. This was a transistive dependancy via spring-context-support:3.0.5. I excluded that library from my build and now the errors pertain to the spring-context-support library.

I have attached a screenshot to illustrate.

Markers

This question is tagged with java maven m2eclipse sts-springsourcetoolsuite m2e

~ Asked on 2012-01-13 22:16:01

The Best Answer is


92

Indeed IDEs often cache the local repository (Eclipse does something similar, and I have to relaunch Eclipse).

One ugly maven behavior you might encounter is that if you declare a dependency before you actually install it, maven will create an empty version of the missing dependency (folder with metadata but no jar), and you will have to manually clean your .m2 repository.

Third, an installed archive (jar...) can get corrupted, so try to open it with any archive tool (7zip...) to test it, and delete the whole folder if the archive is corrupted.

~ Answered on 2012-04-12 12:03:34


17

In my case I had to manually delete all the files in .m2\repository folder and then open command prompt and run mvn -install command in my project directory.

~ Answered on 2014-04-22 14:46:03


Most Viewed Questions: