Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven 3: Maven in 5 minutes "mvn archetype:generate..." command NOT WORKING

Tags:

java

maven-3

I installed Maven 3.1.1 for the first time. In the "Maven in 5 Minutes" getting-started guide

http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html

it says to verify the installation with

mvn --version

I got the expected response:

Apache Maven 3.1.1 (0728685237757ffbf44136acec0402957f723d9a; 2013-09-17 11:22:22-0400)
Maven home: C:\applications\programming\apache-maven-3.1.1
Java version: 1.6.0_17, vendor: Sun Microsystems Inc.
Java home: C:\applications\programming\java_6_17\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "x86", family: "windows"

In the next step, under "Creating a project" it says to create a new directory, open a command prompt in that directory, and execute

mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

I created a directory called xjmaven, ran the command in it, and it's not working. This is the response:

[R:\jeffy\programming\sandbox\xjmaven]mvn archetype:generate -DgroupId=xbnjava -DartifactId=XBN-Java -Darchetype ArtifactId=maven-archetype-quickstart -DinteractiveMode=false
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.251s
[INFO] Finished at: Sat Nov 23 12:11:56 EST 2013
[INFO] Final Memory: 2M/4M
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (R:\jeffy\programming\sandbox\xjmaven). Please verify you invoked Maven from the correct directory. -> [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.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MissingProjectException

I looked up the parameters groupId, artifactId and archetypeArtifactId, and have tried some different values (as you can see above), but I still get the same BUILD FAILURE response.

I manually put the pom.xml file (from in the same webpage) in the xjmaven directory, and ran it again. It downloaded a bunch of stuff (although not to xjmaven), but then failed with this message:

[INFO] Generating project in Interactive mode
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/archetypes/true/1.0/true-1.0.jar
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Skipping Maven Quick Start Archetype
[INFO] This project has been banned from the build due to previous failures.
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 45.047s
[INFO] Finished at: Sat Nov 23 12:04:01 EST 2013
[INFO] Final Memory: 7M/17M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.2:generate (default-cli) on project XBN-Java: The desired archetype does not exist (org.apache.maven.archetypes:true:1.0) -> [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.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

Repeating the command gives this response:

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Quick Start Archetype 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:2.2:generate (default-cli) @ XBN-Java >>>
[INFO]
[INFO] <<< maven-archetype-plugin:2.2:generate (default-cli) @ XBN-Java <<<
[INFO]
[INFO] --- maven-archetype-plugin:2.2:generate (default-cli) @ XBN-Java ---
[INFO] Generating project in Interactive mode
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Skipping Maven Quick Start Archetype
[INFO] This project has been banned from the build due to previous failures.
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.444s
[INFO] Finished at: Sat Nov 23 12:04:32 EST 2013
[INFO] Final Memory: 8M/14M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.2:generate (default-cli) on project XBN-Java: The desired archetype does not exist (org.apache.maven.archetypes:true:1.0) -> [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.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

I deleted pom.xml (it's the only file in the directory...the stuff it downloaded is not there), and started over again. Everything happens (badly) as I write above.


I remember trying Maven a few years ago, and could also not get past the getting-started stage.

If anyone has some advice on how to get past this, it would be appreciated. Really frustrated.

like image 507
aliteralmind Avatar asked Nov 23 '13 17:11

aliteralmind


People also ask

Which of the command is used to generate maven archetype?

To create an archetype manually, we can start with a newly created Maven project and then we can add the resources mentioned above. Or, we can generate it by using the archetype-maven-plugin, and then customize the content of the archetype-resources directory and archetype-metadata. xml file.

What is mvn archetype?

In short, Archetype is a Maven project templating toolkit. An archetype is defined as an original pattern or model from which all other things of the same kind are made. The names fits as we are trying to provide a system that provides a consistent means of generating Maven projects.

How do I run maven archetype in eclipse?

first via the File New Other Maven Maven Project entry. On the archetype selection, select the maven-archetype-webapp entry and click the Next button. Enter the group, artifact and version of your new Maven component.


2 Answers

Maybe you are using Windows PowerShell?

If so, you'll need to put quotes around the parameter definitions:

mvn archetype:generate "-DarchetypeGroupId=org.apache.maven.archetypes" "-DgroupId=com.mycompany.app" "-DartifactId=my-app"
like image 87
Ergwun Avatar answered Sep 22 '22 11:09

Ergwun


You have some syntactical errors while executing the generate goal. Moreover, you need not create the pom.xml or any dir sturcture. You will notice that the generate goal creates a directory with the same name given as the artifactId.

e.g. you are missing the convention like -DgroupId should be com.company.app (not a big issue though), having space in -Darchetype ArtifactId, etc.

I just tried below and it worked :

mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
like image 29
Snehal Masne Avatar answered Sep 18 '22 11:09

Snehal Masne