Create a Maven project in Eclipse complains "Could not resolve archetype"

JavaEclipseMaven

Java Problem Overview


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.

Java Solutions


Solution 1 - Java

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: > - Catalog File: https://repo1.maven.org/maven2/archetype-catalog.xml > - Description: maven catalog

Solution 2 - Java

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.

Solution 3 - Java

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>

Solution 4 - Java

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).

Solution 5 - Java

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.

Solution 6 - Java

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

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

Solution 7 - Java

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

Solution 8 - Java

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

Solution 9 - Java

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.

Solution 10 - Java

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

Solution 11 - Java

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.

Solution 12 - Java

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.

Solution 13 - Java

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

Solution 14 - Java

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionmarcos82View Question on Stackoverflow
Solution 1 - JavaTomDestryView Answer on Stackoverflow
Solution 2 - JavaOh Chin BoonView Answer on Stackoverflow
Solution 3 - JavaChannaBView Answer on Stackoverflow
Solution 4 - JavaErasmus Mann LarbiView Answer on Stackoverflow
Solution 5 - JavafcmView Answer on Stackoverflow
Solution 6 - JavaKarthik PalanisamyView Answer on Stackoverflow
Solution 7 - Javajava.nazifView Answer on Stackoverflow
Solution 8 - JavaPrateek RathoreView Answer on Stackoverflow
Solution 9 - JavaMandar_PView Answer on Stackoverflow
Solution 10 - JavaHarsh GuptaView Answer on Stackoverflow
Solution 11 - JavaJstnPwllView Answer on Stackoverflow
Solution 12 - JavaAlexis DufrenoyView Answer on Stackoverflow
Solution 13 - JavaAkshadaView Answer on Stackoverflow
Solution 14 - JavaRajanView Answer on Stackoverflow