Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven build fails in eclipse; successful from command line [closed]

Tags:

eclipse

maven

My maven project in Eclipse Kepler will not build when invoking "Run As -> maven install" or "Run As-> Maven build.... clean install".

I get the following error:

[ERROR] Failed to execute goal on project SSLibrary: Could not resolve dependencies for project com.SSLibrary:jar:1.1.0-SNAPSHOT: Could not find artifact org.jacorb:jacorb:jar:2.3.2-redhat-4 in artifactory-releases (xxx/libs-release-local) -> [Help 1]

My pom.xml in eclipse has a red x stating:

Multiple annotations found at this line: - Missing artifact org.jacorb:jacorb:jar:2.3.2-redhat-4 - Missing artifact com.sun:tools:jar:1.6

However, executing a mvn install from the command line is successful. I can also see the org.jacorb.jacorb.jar file, version 2.3.2-redhat-4, in my local repo.

Its almost like Eclipse is playing by different rules.

like image 576
Samhain Avatar asked Nov 07 '14 15:11

Samhain


1 Answers

There can be a couple of reasons why a Maven build fails in Eclipse but works by command line.

  • Check if you are using the same Maven installation in Eclipse and in your command line. To do so, check your system path and compare it with the version used in Eclipse, which you can find in the Eclipse Preferences screen: Maven->Installations. Maybe you are using the embedded version?
  • Check if you are using the same settings.xml file. In Maven, it is in your ${MAVEN_HOME}/conf directory. In Eclipse, you can specify another file, also in the Eclipse Preferences screen: Maven->User Settings
  • Also, check the local repository in that screen is the same as the one defined in the settings.xml
  • Make sure you are using the same Java version Java in Eclipse and Maven.
  • You can try to delete the problematic dependency in your local repository in order to cause a re-download
  • In case you're using other Eclipse projects as dependencies, you can try to disable workspace dependecies resolution by right-clicking on the project and choosing Maven -> Disable Workspace Resolution (you'll have to have the other project artifacts installed in your local repo first)
  • If nothing else helps and you're using a proxy like Nexus or Archiva, try to unzip your jar file by hand in order to check its integrity (can you see classfiles inside?). If the jar is not correct or non-existant, contact the proxy administrator.

Edit: In order to try to solve the issue about the error shown by Eclipse in the pom.xml file, once you have checked the previous points (the last one is not needed, in that case), you can also try this:

  • Right click on your project in the Package/Project Explorer. Select Maven->Update project. This will update the Eclipse project settings accordingly to your Maven settings. Then run a Maven clean + install
like image 135
Alexis Dufrenoy Avatar answered Nov 15 '22 19:11

Alexis Dufrenoy