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

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 related to java maven m2eclipse sts-springsourcetoolsuite m2e

The answer is


I faced this problem. I had "Archive for required library spring-boot-devtools cannot be read or is not a valid ZIP file" and the solution was like that:- 1- determine the dependencies names that have problems(for may case it is spring-boot-devtools). 2- close eclipse. 3- search in your .m2 file on these dependencies(by name). 4- delete these folders. 5- reopen eclipse and let maven rebuild your dependencies again.


In my case I tried all the tips suggested but the error remained. I solved changing with a more recent version and writing that in the pom.xml. After this everything is now ok.


Just had this problem on Indigo SR2. It popped up after I removed a superfluous jar from the classpath (build path). Restarting Eclipse didn't help. Added back the jar to the build path...error went away. Removed the jar once again, and this time I was spared from another complaint.


Read the issue in Problems section,identify which dependency not able to read, then go the maven repository .m2\repository -> 1)check the dependencies and delete it from the folder 2)go to STS/Eclipse -> click on maven -> update project ->select the force update of snapshots/releases and click on ok.

or delete the dependencies from the .m2/repository and rebuild the maven --> update the maven project


Remove maven dependenices from build path


In case of VSCode, follow the below steps:

  1. Navigate to the respective folder that contains the corrupted jar
  2. Delete just the jar
  3. mvn clean
  4. mvn compile

That worked for me.


This worked for me.

  1. Close Eclipse
  2. Delete ./m2/repository
  3. Open Eclipse, it will automatically download all the jars
  4. If still problem remains, then right click project > Maven > Update Project... > Check 'Force Update of Snapshots/Releases'

Delete your C:\Users\PC\.m2** folder
and update maven project 

This could be due to you have added spring-licence.txt file to your web app libraries.

I had similar issue and resolved after removing that text file. In libraries it will expect jar file only.


Below Steps resolved my issue.

  1. Go to ./m2/repository folder.

  2. Go to respective archive error folder.

  3. Verify any zip file is exist.

  4. delete error name folder.

  5. Now come to Eclipse Project - Right Click - Maven - > Update Project.

Above trick works for me.


I was facing the same problem with my project.

My project was not able to find this archive: -

C:\Users\rakeshnarang\.m2\repository\org\hibernate\hibernate-core\5.3.7.Final

I went to this directory and deleted this folder.

Went back to eclipse and hit ALT + F5 to update the project.

The jar file was downloaded again and the problem was solved.

You should try this.


I face with the same issue. I deleted the local repository and relaunched the ID. It worked fine .


Delete corrupted files from your local .m2 repository and Ctrl+F5 (Update Maven Project) in Eclipse/STS. It'll download and install these files.


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.


Ok, I had the same problem with STS on a mac and solved it by deleting all the files in repository folder and from the STS IDE click on the project and then Maven -> Update project. Give it a couple of minutes to download all the dependencies and the problem is solved.


Alternatively, below commands also worked for me:

mvn -s settings.xml eclipse:clean
mvn -s settings.xml eclipse:eclipse

This happens when Eclipse screws up. To fix it, delete all the files in:

workspace/.metadata/.plugins/org.eclipse.jdt.core

When I got an error saying "archive for required library could not be read," I solved it by removing the JARS in question from the Build Path of the project, and then using "Add External Jars" to add them back in again (navigating to the same folder that they were in). Using the "Add Jars" button wouldn't work, and the error would still be there. But using "Add External Jars" worked.


none of the solutions above helped my problem. I've resolved it by deleting all files in {projectworkspace}/.metadata folder AND in {location}/.m2 folder and let eclipse download every single thing again. Hope this helps someone, cheers!


I deleted the local maven repository. Then just rightclick the project -> Maven -> Update Project... Select all concerned projects and click OK.


I was using Eclipse as IDE and I was getting very same error. I had to do Project->Maven->Update Project. Select all the checkboxes below except "offline" esp. the one "Force update of snapshots/releases" and click OK. Did the Clean Build for the Project again.


For Googlers:

In my case I had accidentally manually added a Java class to the build path while poking around Eclipse. By taking a look at the 'Configure Build Path...> Libraries I removed the culprit class and now only have the

  • JRE System Library
  • Maven Dependencies

and nothing is complaining.


Examples related to java

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How much should a function trust another function How to implement a simple scenario the OO way Two constructors How do I get some variable from another class in Java? this in equals method How to split a string in two and store it in a field How to do perspective fixing? String index out of range: 4 My eclipse won't open, i download the bundle pack it keeps saying error log

Examples related to maven

Maven dependencies are failing with a 501 error Why am I getting Unknown error in line 1 of pom.xml? Why am I getting "Received fatal alert: protocol_version" or "peer not authenticated" from Maven Central? How to resolve Unable to load authentication plugin 'caching_sha2_password' issue Unable to compile simple Java 10 / Java 11 project with Maven ERROR Source option 1.5 is no longer supported. Use 1.6 or later 'react-scripts' is not recognized as an internal or external command How to create a Java / Maven project that works in Visual Studio Code? "The POM for ... is missing, no dependency information available" even though it exists in Maven Repository Java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/exc/InvalidDefinitionException

Examples related to m2eclipse

web.xml is missing and <failOnMissingWebXml> is set to true How to solve maven 2.6 resource plugin dependency? No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK? An internal error occurred during: "Updating Maven Project". java.lang.NullPointerException An internal error occurred during: "Updating Maven Project". Unsupported IClasspathEntry kind=4 Maven "build path specifies execution environment J2SE-1.5", even though I changed it to 1.7 Failed to resolve version for org.apache.maven.archetypes Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of its dependencies could not be resolved How to deal with missing src/test/java source folder in Android/Maven project? SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". error

Examples related to sts-springsourcetoolsuite

Compiler error "archive for required library could not be read" - Spring Tool Suite Maven2: Missing artifact but jars are in place

Examples related to m2e

m2e error in MavenArchiver.getManifest() Maven Java EE Configuration Marker with Java Server Faces 1.2 How to deal with missing src/test/java source folder in Android/Maven project? Compiler error "archive for required library could not be read" - Spring Tool Suite m2e lifecycle-mapping not found