Ivy Retrieve Failure: java.lang.RuntimeException: Multiple artifacts of the module org.springframework#spring-context;5.3.34 are retrieved to the same file!
search cancel

Ivy Retrieve Failure: java.lang.RuntimeException: Multiple artifacts of the module org.springframework#spring-context;5.3.34 are retrieved to the same file!

book

Article ID: 423259

calendar_today

Updated On:

Products

VMware Tanzu Spring Essentials

Issue/Introduction

While resolving Spring dependencies using ANT + Apache Ivy, the build fails during ivy:retrieve with the following error:

impossible to ivy retrieve: java.lang.RuntimeException: problem during retrieve of demo#spring-ant-broadcom-demo: java.lang.RuntimeException: Multiple artifacts of the module org.springframework#spring-context;5.3.34 are retrieved to the same file! Update the retrieve pattern to fix this error.
	at org.apache.ivy.core.retrieve.RetrieveEngine.retrieve(RetrieveEngine.java:238)
	at org.apache.ivy.Ivy.retrieve(Ivy.java:561)
	at org.apache.ivy.ant.IvyRetrieve.doExecute(IvyRetrieve.java:113)
	at org.apache.ivy.ant.IvyTask.execute(IvyTask.java:259)
	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:299)

 

This typically happens when downloading artifacts from an enterprise repository (e.g., Broadcom Spring Enterprise repo) and retrieving them into a local lib/ folder.

Cause

The ivy:retrieve pattern in build.xml maps different artifacts from the same module to the same destination filename.

For example, Ivy may retrieve:

  • the main binary JAR (spring-context-5.3.34.jar)
  • and an additional artifact such as sources or javadoc (or another classified jar)

If the retrieve pattern does not include the classifier, Ivy tries to save both artifacts with the same name (e.g., spring-context-5.3.34.jar), causing a collision and the runtime exception.

Resolution

Update the ivy:retrieve pattern to include the classifier so that different artifacts are written to different filenames. Example, below is an ivy retrieve pattern to download different artifacts separated by module folder.

<ivy:retrieve
  pattern="${lib.dir}/[organisation]/[module]/[artifact]-[revision](-[classifier]).[ext]"/>