Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven error when resolving dependency

I am new to Maven and am trying to set up one of my first POMs. My application will cache using EhCache. Going to Maven Central Repo (link here) I copy-n-pasted the <dependency> tag and copy it into my pom.xml like so:

...many dependencies above this point
<dependency>
    <scope>compile</scope>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-entitymanager</artifactId>
    <version>4.0.1.Final</version>
</dependency>
<dependency>
    <scope>compile</scope>
    <groupId>net.sf.ehcache</groupId>
    <artifactId>ehcache</artifactId>
    <version>2.5.0</version>
</dependency>
<dependency>
    <scope>compile</scope>
    <groupId>jasperreports</groupId>
    <artifactId>jasperreports</artifactId>
    <version>3.5.3</version>
</dependency>
...many dependencies below this point

When I save the changes, Eclipse builds the workspace and gives me an error on the opening <dependency> tag for EhCache 2.5:

Missing artifact net.sf.ehcache:ehcache:jar:2.5.0

So I figured that perhaps v.2.5.0 has something wrong with it, and repeated the same for 2.4.7 (the last 2.4.x release before 2.5.0). Same deal.

Since I'm so new to Maven, I don't even know where to begin looking. I tried Project >> Clean and even restarted Eclipse to see if it was just a typical Eclipse "quirk". Nope.

I am thinking:

  • Could EhCache be publishing bad JARs to the Maven repo?
  • Could Maven Repo have something wrong with it?
  • Could this be due to something else configured wrong in my pom.xml?
  • Could this be a "JAR hell" issue where I have a conflict somewhere on my dependency graph?

How would SO start tackling this problem? Thanks in advance!

like image 958
IAmYourFaja Avatar asked Jan 21 '12 15:01

IAmYourFaja


People also ask

What does Mvn dependency resolve do?

Description: Goal that resolves the project dependencies from the repository.


2 Answers

It is usually safer to refer to search.maven.org. Dependency from there:

<dependency>
    <groupId>net.sf.ehcache</groupId>
    <artifactId>ehcache</artifactId>
    <version>2.5.0</version>
    <type>pom</type>
</dependency>

Mind type pom. From module's pom:

This is a pom artifact to pull in ehcache-core and ehcache-terracotta for clustering. Make sure to set 'type' to 'pom' in your dependency.

Aparently when someone does not need terracotta, ehcache-core will do perfectly fine as other answer states.

like image 89
mrembisz Avatar answered Oct 02 '22 04:10

mrembisz


They use ehcache-core in the official documentation. Maven Central does not have a jar artifact for ehcache 2.5 which explains your error message.

Using ehcache-core changes the dependency to:

<dependency>
  <groupId>net.sf.ehcache</groupId>
  <artifactId>ehcache-core</artifactId>
  <version>2.5.0</version>
</dependency>

Which successfully downloads on my machine (ehcache does not).

like image 37
Kai Sternad Avatar answered Oct 02 '22 06:10

Kai Sternad