26

A friend has passed me a Maven project that I'm trying to run locally in my computer. All that I have done in Eclipse, I selected:

File -> Import -> Existing Maven Projects

After that, the project showed me 4 errors in my pom.xml (Missing artifact..):

enter image description here

I tried removing the content of .m2 folder and then in Eclipse I clicked on my project and chose "Run as" -> "Maven clean" and then "Run as" -> "Maven install". But I still have the same errors. I'm new with Spring so I dont know what else to do.

EDIT:

When I try to do: run as/ maven install, this is what my console says:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building DataLayer 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for javax.persistence:javax.persistence:jar:1.0.0 is missing, no     dependency information available
[WARNING] The POM for hibernate-core:hibernate-core:jar:4.2.1.Final is missing, no     dependency information available
[WARNING] The POM for hibernate-commons-annotations:hibernate-commons-annotations:jar:4.0.1.Final is missing, no dependency information available
[WARNING] The POM for jboss-logging:jboss-logging:jar:3.1.0.CR2 is missing, no dependency information available
[WARNING] The POM for jta:jta:jar:1.1 is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.065s
[INFO] Finished at: Wed Aug 07 11:41:45 VET 2013
[INFO] Final Memory: 4M/90M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project DataLayer: Could not resolve dependencies for     project SocialManager:DataLayer:jar:0.0.1-SNAPSHOT: The following artifacts could not be resolved: javax.persistence:javax.persistence:jar:1.0.0, hibernate-core:hibernate-core:jar:4.2.1.Final, hibernate-commons-annotations:hibernate-commons-annotations:jar:4.0.1.Final, jboss-logging:jboss-logging:jar:3.1.0.CR2, jta:jta:jar:1.1: Failure to find javax.persistence:javax.persistence:jar:1.0.0 in http://repository.jboss.org/nexus/content/groups/public/ was cached in the local repository, resolution will not be reattempted until the update interval of JBoss repository has elapsed or updates are forced -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.

EDIT2: This is my complete pom.xml: https://dl.dropboxusercontent.com/u/31349296/pom.xml It looks pretty awful when I try to paste the code here.

BuZZ-dEE
  • 6,075
  • 12
  • 66
  • 96
kiduxa
  • 3,339
  • 11
  • 37
  • 52

8 Answers8

25

It seemed that a lot of dependencies were incorrect.

enter image description here

Download the whole POM here

A good place to look for the correct dependencies is the Maven Repository website.

Bart
  • 17,070
  • 5
  • 61
  • 80
  • Do I have to add those lines at the end of my pom.xml? or it should be in other file?. After that what do I have to do? thanks :) – kiduxa Aug 07 '13 at 16:08
  • 1
    This needs be entered in settings.xml – Lokesh Aug 07 '13 at 16:09
  • It needs to be in the `` tag but you could just add it before ``. – Bart Aug 07 '13 at 16:09
  • @loki It doesn't have to be settings.xml perse – Bart Aug 07 '13 at 16:10
  • 2
    @loki it can live in the project's pom or within settings.xml. If it's in the project's pom.xml then you avoid problems like this. if it's in the settings.xml, then you avoid polluting the project poms with repository information. – digitaljoel Aug 07 '13 at 16:12
  • @Bart: If not settings.xml then in which file you make this entry? – Lokesh Aug 07 '13 at 16:12
  • @loki It's perfectly valid inside your pom.xml – Bart Aug 07 '13 at 16:13
  • @Bart I did what you said: added those lines in my pom.xml and then I tried cleaning and installing, but I still have the same problem. Actually, when I try: run as/ install maven I have some specific warnings (shown above in the question) – kiduxa Aug 07 '13 at 16:18
  • Could you add the complete POM (and settings.xml if you have one)? – Bart Aug 07 '13 at 16:21
  • You should thank your friend for giving you a POM with many broken dependencies. Thank him with a kick in the butt ;) All the dependencies resolve now. I will update my answer in a few minutes – Bart Aug 07 '13 at 16:59
  • Thanks @Bart it worked!!. May I ask, how did you found out that the dependencies were wrong and how did you get the correct ones? – kiduxa Aug 07 '13 at 17:16
  • 1
    @kiduxa Included it in the answer. Good luck – Bart Aug 07 '13 at 17:19
8

I know it is an old question. But I hope my answer will help somebody. I had the same issue and I think the problem is that it cannot find those .jar files in your local repository. So what I did is I added the following code to my pom.xml and it worked.

<repositories>
  <repository>
      <id>spring-milestones</id>
      <name>Spring Milestones</name>
      <url>https://repo.spring.io/libs-milestone</url>
      <snapshots>
          <enabled>false</enabled>
      </snapshots>
  </repository>
</repositories>
Octtavius
  • 563
  • 8
  • 29
1

It means maven is not able to download artifacts from repository. Following steps will help you:

  1. Go to repository browser and check if artifact exist.
  2. Check settings.xml to see if proper respository is specified.
  3. Check proxy settings.
Lokesh
  • 7,810
  • 6
  • 48
  • 78
  • 1
    could you please be more specific?. How is that "Go to repository browser and check if artifact exist"? and where is settings.xml located? thank you :) – kiduxa Aug 07 '13 at 16:07
  • Well, maven downloads artifacts from repository and repository have web browser for it but in your case these are standard jars , so this step can be skipped. settings.xml can be found under .m2 folder. – Lokesh Aug 07 '13 at 16:08
  • inside .m2 folder there is another folder called "repositories" but there is no settings.xml neither inside the "repositories" folder :S. – kiduxa Aug 07 '13 at 16:15
  • it should be placed there along with repository folder. Your setup seems to be not correct. Also you mentioned in your post that you deleted contents of .m2 folder, so might have been deleted. – Lokesh Aug 07 '13 at 16:18
  • Is there anyway to regenerate the settings.xml file? – kiduxa Aug 07 '13 at 16:21
  • @kiduxa settings.xml will add attributes to all maven projects. If you don't need that to happen you can just delete it. It's not mandatory. – Bart Aug 07 '13 at 16:24
  • @Bart well it seems that I dont have the settings.xml file. I cant say if I ever had it. But I only have one project Maven.. – kiduxa Aug 07 '13 at 16:30
1

This is a very late answer,but this might help.I went to this link and searched for ojdbc8(I was trying to add jdbc oracle driver) When clicked on the result , a note was displayed like this:

enter image description here

I clicked the link in the note and the correct dependency was mentioned like below enter image description here

1

I was running into this trying to resolve a separate issue with a Maven/Java/Selenium/Cucumber project. For some reason, even though the Maven repo page for com.google.guava snippet had this in it, I resolved this by removing bundle from it.

<dependency>
  <groupId>com.google.guava</groupId>
  <artifactId>guava</artifactId>
  <version>31.1-jre</version>
  <!--type>bundle</type-->
</dependency>

Exact error message:

Missing artifact com.google.guava:guava:bundle:31.1-jre

I also found this article helpful. How to Debug Dependency Conflicts in Maven and Gradle

0

I somehow had this issue after I lost internet connection. I was able to fix it by updating the Maven indexes in Eclipse and then selecting my project and updating the Snapshots/releases.

Pablo Gonzalez
  • 1,710
  • 3
  • 21
  • 36
0

SIMPLE..

First check with the closing tag of project. It should be placed after all the dependency tags are closed.This way I solved my error. --Sush happy coding :)

sush
  • 1
  • 1
0

In my case, My STS was pointing to JRE. I have modified the build path to connect with JDK.

Once I connected to JDK, the pom.xml issue was resolved.

vaibhav singhal
  • 883
  • 8
  • 9