75

I am totally a newbie with Maven. I want to create a Maven project with Eclipse Juno EE with archetype "webapp". I installed "Maven Integration for Eclipse WTP (incubation)" and I also have installed "Maven Integration for Eclipse" (found it on Installed tab of Eclipse Marketplace). When I try to create new Project from File->New_>Maven Project, I obtain error:

Could not resolve archetype org.apache.maven.archetypes:maven-archetype-webapp:RELEASE from any of the configured repositories.
Could not resolve artifact org.apache.maven.archetypes:maven-archetype-webapp:pom:RELEASE
Failed to resolve version for org.apache.maven.archetypes:maven-archetype-webapp:pom:RELEASE: Could not find metadata org.apache.maven.archetypes:maven-archetype-webapp/maven-metadata.xml in local (C:\Documents and Settings\PEP35KD\.m2\repository)
Failed to resolve version for org.apache.maven.archetypes:maven-archetype-webapp:pom:RELEASE: Could not find metadata org.apache.maven.archetypes:maven-archetype-webapp/maven-metadata.xml in local (C:\Documents and Settings\PEP35KD\.m2\repository)

It happens for all kinds of archetype. I am using a proxy, and I create file settings.xml under C:\Documents and Settings\PEP35KD.m2\ with this content:

<proxies>
    <proxy>
        <id>myId</id>
        <active>true</active>
        <protocol>http</protocol>
        <username>rete\pep35kd</username>
        <password>XXXX</password>
        <host>XXXX</host>
        <port>8080</port>
        <nonProxyHosts>localhost</nonProxyHosts>
    </proxy>
</proxies>

Please, consider that it seems that I cannot use mvn command from command line (command not found). I never installed Maven itself, I thinked that plugin is just enough: is it a correct assumption?

UPDATE Problem is definitely related to proxy. By:

  • Installing Maven on local PC;
  • Installing Maven Eclipse from Eclipse Market Place;
  • Setting Maven Install directory to local PC Maven dir, instead of default Embedded Maven,

everything works as expected. I cannot really understand why, but probably firewall is blocking traffic with Maven servers.

Raedwald
  • 46,613
  • 43
  • 151
  • 237
marcos82
  • 997
  • 1
  • 8
  • 11

14 Answers14

151

I fixed this problem by following the solution to this other StackOverflow question

I had the same problem. I fixed it by adding the maven archetype catalog to eclipse. Steps are provided below: (Please note the https protocol)

  1. Open Window > Preferences
  2. Open Maven > Archetypes
  3. Click 'Add Remote Catalog' and add the following:
Juan
  • 13
  • 4
TomDestry
  • 3,349
  • 5
  • 31
  • 40
12

Assuming that you have your proxy settings correct, you may have missed out pointing Eclipse to the intended settings.xml file. This happens often when you have both Maven installed as a snap in, and an external installation outside Eclipse. You need to tell Eclipse which Maven installation it should use, and which settings.xml file it should be looking for.

First check that the settings.xml file contains your proxy settings.

enter image description here

Next, check that the user settings.xml file here contains your proxy settings.

enter image description here

If you have made any changes, restart Eclipse.

Oh Chin Boon
  • 23,028
  • 51
  • 143
  • 215
10

Adding the following inside "mirrors" section in the user setting.xml file worked for me.

<mirror>
  <id>ibiblio.org</id>
  <url>http://mirrors.ibiblio.org/maven2</url>
  <mirrorOf>central</mirrorOf>
</mirror>
ChannaB
  • 439
  • 4
  • 13
  • This is the solution that worked for me. There are also some others mirrors that can be used (`uk.maven.orghttp://uk.maven.org/maven2`, `centralhttp://repo1.maven.org/maven2`, etc.). This URL can be useful: http://repo.maven.apache.org/maven2/.meta/repository-metadata.xml . – ROMANIA_engineer Nov 05 '15 at 10:41
7

i found the easiest way was to just remove/delete the .m2 folder and recreate it, putting back your settings.xml configuration details(if applicable).

6

Add your MAVEN_HOME environment variable, edit your Path to include %MAVEN_HOME%/bin then try creating the project manually with Maven:

mvn archetype:generate -DgroupId=com.program -DartifactId=Program -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false

Then import the existing Maven project to Eclipse.

fcm
  • 6,305
  • 5
  • 24
  • 37
  • I cannot use "mvn" command line. Is it necessary to install Maven before the Eclipse plugin? It can seem a obvious question, but I expected some error from Eclipse if Maven was required and not available. – marcos82 Mar 19 '13 at 17:17
  • To use the mvn command, you have to add the enviroment variable. Se here for more information: https://confluence.sakaiproject.org/pages/viewpage.action?pageId=37290050 – fcm Mar 19 '13 at 17:18
  • Also, of course, if you haven't yet, you have to configure maven so it works correctly on Eclipse. Go to Window -> Preferences -> Maven, and it's all there (Installation dir, settings, etc.) – fcm Mar 19 '13 at 17:21
  • I cannot find Maven directory installation on PC. From this link http://stackoverflow.com/questions/289800/where-can-i-find-the-maven-installation-directory-in-eclipse-3-4, I understand that I need full Maven installation to use it on command line, isn't it? – marcos82 Mar 19 '13 at 17:28
  • Under Windows-Preferences->Maven->Installations, installation selected to launh Maven is set to Embedded (no path) – marcos82 Mar 19 '13 at 17:29
  • Download maven here: http://maven.apache.org/ - Extract it to C:\, then you're good to go. Embedded Maven is annoying to mess with the configuration, always set your own. – fcm Mar 19 '13 at 17:38
  • I installed Maven, set Maven installation to new installed software, but creating project from Eclipse still gives same error. Also using suggested command line I obtain Build Failure (lots of failing to retireve plugin description and "No plugin found for prefix 'archetype' in the current project and in the plugin groups" – marcos82 Mar 19 '13 at 17:54
  • Are you behind a proxy? In that case, edit settings.xml (C:\apache-maven-3.0.4\conf\settings.xml) to add that information there. – fcm Mar 19 '13 at 17:58
  • Yes, I added proxy section (see my first post... I just covered password and host section with XXX) – marcos82 Mar 19 '13 at 18:02
  • I used settings.xml (with my proxy added) from conf directory of Maven install dir also in .m2 user directory... – marcos82 Mar 19 '13 at 18:07
4

You can resolve it by configuring settings.xml in Eclipse.

Go to Window --> Preferences --> Maven --> User Settings --> select the actual path of settings.xml

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
3

I find it solution http://www.scriptscoop.net/t/7c42f9d698a4/java-create-maven-project-could-not-resolve-archetype-connection-refused.html

We can see the origin of the problem : Connection refused: connect

I have already do this :

1) Window -> Preferences -> General -> Network Connections. I put in Manual with the url and port of my proxy for HTTP protocol. It works because before this, Spring Tool Suite did not want to update. After, it's okay.

2) Window -> Preferences -> Maven -> User Settings. In Global Settings, is empty. In User Settings, I put the path to settings.xml. In this file, i have :

enter image description here

java.nazif
  • 713
  • 1
  • 9
  • 18
2

Goto Preferences: -> Maven Click 'Add Remote Catalog' File: http://repo1.maven.org/maven2/archetype-catalog.xml Desc: Catalog

2

click windows-> preferences->Maven. uncheck "Offline" check box. This was not able to download archetype which I was using. When I uncheck it, Everything worked smooth.

Mandar_P
  • 51
  • 6
1

It is also possible that your settings.xml file defined in maven/conf folder defines a location that it cannot access

Harsh Gupta
  • 197
  • 6
1

This might sound silly, but make sure the "Offline" checkbox in Maven settings is unchecked. I was trying to create a project and got this error until I noticed the checkbox.

JstnPwll
  • 8,585
  • 2
  • 33
  • 56
0

First things first, you have to install Maven on your workstation. You need also to install M2E, what you obviously did. Not all distributions of Juno have it pre-installed.

Then configure your Eclipse so it can find your Maven install. In the menu Window -> Preferences, then open the Maven section. In your right panel, you have a list of the Maven installations Eclipse knows. Add your installation and select it instead of the embedded Maven provided with M2E. Don't forget to set the "Global settings from installation directory" field with the path to the settings.xml of your Maven installation.

Which leads us to the settings.xml. If the above doesn't solve your problem, you will have to configure your Maven. More infos here.

Alexis Dufrenoy
  • 11,784
  • 12
  • 82
  • 124
  • 1
    I installed Maven, set Maven installation to new installed software, but creating project from Eclipse still gives same error. I tried to lanunbch this command from command line: mvn archetype:generate -DgroupId=com.program -DartifactId=Program -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false but I have a lot of errors like this: Plugin org.apache.maven.plugins:maven-clean-plugin:2.4.1 or one of its dependencies could not be resolved And final build failure: No plugin found for prefix 'archetype' in the current project and in the plugin groups – marcos82 Mar 19 '13 at 17:51
0

I was getting similar error while creating web-app in eclipse and resolved the problem just by cleaning (deleting all files from) and rebuilding the maven repository

Akshada
  • 190
  • 3
  • 12
-3

You will need to install the m2eclipse or any other maven plugin in your eclipse. Some eclipse come with maven and its plugins installed. Otherwise go to Help->software Install, select All sites, filter list with maven, and then install the plugin. Then look at this link. Hope it helps.

Rajan
  • 1,501
  • 4
  • 21
  • 37