Groovy - Grab - download failed

It looks like your Grape settings are set only to look in your local .m2 directory for the library. Check your grapeConfig.xml configuration file. (If you don't have one, you can create it--it should go in the same directory where your groovysh.history and grapes cache directory are created by Groovy.) You can copy the example file shown on the Groovy Grape reference page.

If that doesn't help, I would try deleting your grapes cache directory and try it again.


My problem was, groovy (v2.4.8) was looking in the maven repository fist (~/.m2/repository/) and finding the pom file but not finding the associated artifact/JAR. Instead of just moving on to the next resolver, which would have succeeded, it just gives up. The workaround would be to remove the pom file, the specific directory cache, or just temporarily rename the repository and run groovy again as other suggested. Or you could try to manually add it to the repository. But these are just temporary and you'll likely run into the issue again if you clear your groovy cache or with another dependency.

To troubleshoot this issue you can turn on verbose logging and try to manually install the dependency. So if your error is something like:

java.lang.RuntimeException: Error grabbing Grapes -- [download failed: commons-logging#commons-logging;1.1.1!commons-logging.jar, download failed: commons-codec#commons-codec;1.6!commons-codec.jar, download failed: commons-lang#commons-lang;2.4!commons-lang.jar]
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)

Which means your dependency is commons-logging-1.1.1.jar. You can run:

grape -V install commons-logging commons-logging 1.1.1

What ended up solving the problem for me was overriding the default configuration and setting usepoms="false" in the localm2 resolver. It works in my case because I have the pom but not the JAR, so since Ivy isn't considering the POM now and the JAR was never there to begin with, it goes onto the next resolver which does find it. So in summary:

  • Create this file: ~/.groovy/grapeConfig.xml
  • With these contents:

<ivysettings>
  <settings defaultResolver="downloadGrapes"/>
  <resolvers>
	<chain name="downloadGrapes" returnFirst="true">
	  <filesystem name="cachedGrapes">
		<ivy pattern="${user.home}/.groovy/grapes/[organisation]/[module]/ivy-[revision].xml"/>
		<artifact pattern="${user.home}/.groovy/grapes/[organisation]/[module]/[type]s/[artifact]-[revision](-[classifier]).[ext]"/>
	  </filesystem>
	  <ibiblio name="localm2" root="file:${user.home}/.m2test/repository/" checkmodified="true" changingPattern=".*" changingMatcher="regexp" m2compatible="true" usepoms="false"/>
	  <ibiblio name="jcenter" root="https://jcenter.bintray.com/" m2compatible="true"/>
	  <ibiblio name="ibiblio" m2compatible="true"/>
	</chain>
  </resolvers>
</ivysettings>

I was tempted not to use the maven 2 cache at all, but if I removed the line, I got errors about not being able to find "localm2". Although updating it to point to fictitious directory worked.


Try deleting ~/.m2 directory and also ~/.groovy/grapes directories.

It worked for me.


Deleting .m2 and grapes did not resolve the issue for me as when they were repopulated, the jar was not being downloaded. In my case, I was missing xml-apis-1.3.04.jar

I eventually resolved the issue by manually downloading the jar file and copying it into ~/.m2/repository/xml-apis/xml-apis/<version>

Hopefully this is useful if simply deleting the directories isn't working.

Tags:

Groovy