159

I have a pom.xml in C:\Users\AArmijos\Desktop\Factura Electronica\MIyT\componentes-1.0.4\sources\pom.xml and I executed:

mvn install:install-file -DgroupId=es.mityc.jumbo.adsi -DartifactId=xmlsec-1.4.2-ADSI -Dversion=1.0 -Dpackaging=jar -Dfile=C:\Users\AArmijos\Desktop\Factura Electronica\MIyT\componentes-1.0.4\core\xmlsec-1.4.2-ADSI-1.0.jar

however it returned the error below:

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.310s
[INFO] Finished at: Thu May 02 16:48:29 COT 2013
[INFO] Final Memory: 2M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM
 in this directory (C:\Users\AArmijos). Please verify you invoked Maven from the
 correct directory. -> [Help 1]

Can someone explain why it fails?

user
  • 86,916
  • 18
  • 197
  • 190
Adrian
  • 7,745
  • 5
  • 28
  • 28

20 Answers20

276

This link helped: https://stackoverflow.com/a/11199865/1307104

I edit my command by adding quotes for every parameter like this:

mvn install:install-file "-DgroupId=org.mozilla" "-DartifactId=jss" "-Dversion=4.2.5" "-Dpackaging=jar" "-Dfile=C:\Users\AArmijos\workspace\componentes-1.0.4\deps\jss-4.2.5.jar"

It's worked.

Community
  • 1
  • 1
Adrian
  • 7,745
  • 5
  • 28
  • 28
  • 4
    Since when do I need quotes? I am so puzzled right now, and relieved to finally find an answer to such a rubbish error message ... – BAERUS Jan 04 '18 at 19:50
  • I faced similar issue when doing `deploy:deploy-file`, but my issue was I just missed the dash ("`-`") in front of one of the options. – RAM237 Jun 04 '18 at 17:01
  • 3
    If you're in powershell, you can visually see how PowerShell is separating arguments with the colors on the command line, or by putting "echo" in front of the command. Like, "echo mvn install:install-file...". – turiyag Dec 02 '18 at 22:47
  • 1
    In earlier version of maven, I never used to provide the double-quotes. But, now it doesn't work without it. this solved my issue. – Pankaj Dec 22 '19 at 05:40
  • 1
    This happens due to having spaces in the folder paths. Adding quotes solves the issue or you can just rename the folders having spaces with under-scores or something. – Vidura Yashan Jan 27 '20 at 03:59
73

For any of those who are experiencing this on Windows and none of the above worked, try running this from cmd.exe. Executing these commands via PowerShell caused the install to fail each time.

Josh Sullivan
  • 1,066
  • 9
  • 11
  • 2
    Same issue, Powershell and CMD argument handling work differently and seem to be confusing MVN – eageranalyst Sep 08 '15 at 22:22
  • 1
    Was following Maven's Getting Started guide and trying to execute "mvn -B archetype:generate ....." on Windows PowerShell and was getting similar error. Switching to different command line client (mintty git bash) solved the problem. – AbstractVoid Oct 21 '18 at 16:24
  • 3
    In PowerShell the `.` operator is significant because it's used for object property/method access as with most other .NET languages. If you have dots in the args generally I've quoted these in the past in order to get PowerShell to treat them as literal strings. – jpierson Dec 08 '20 at 15:50
62

On Windows when you are using PowerShell you have to enclose all parameters with quotes.

So if you want to create a maven webapp archetype you would do as follows:

Prerequisites:

  1. Make sure you have maven installed and have it in your PATH environment variable.

Howto:

  1. Open windows powershell
  2. mkdir MyWebApp
  3. cd MyWebApp
  4. mvn archetype:generate "-DgroupId=com.javan.dev" "-DartifactId=MyWebApp" "-DarchetypeArtifactId=maven-archetype-webapp" "-DinteractiveMode=false"

enter image description here

Note: This is tested only on windows 10 powershell

jpierson
  • 16,435
  • 14
  • 105
  • 149
J.Javan
  • 813
  • 8
  • 9
  • Verified on Mac OS X. Also, for dprowizard `java-simple` you can use the following command: `mvn archetype:generate "-DarchetypeGroupId=io.dropwizard.archetypes" "-DarchetypeArtifactId=java-simple"` with interactive mode or with extra parameters. – Andrey Lebedenko Jul 25 '18 at 14:45
  • same problem exists also on command prompt. enclosing parameter values within quotes is the real solution. – Gautam Dec 27 '21 at 05:44
16

Adding one more answer for Windows users. If none of this solves the problems.

Do not add space before or after =

-DgroupId= com.company.module //Wrong , Watch the space after the equal to 
-DgroupId=com.company.module //Right 

Its better to put everything inside double quotes, like "-DgroupId=com.." This will give you exact error rather than some random error.

Weird that , maven does not even care to mention this in the documentation.

madhairsilence
  • 3,787
  • 2
  • 35
  • 76
  • 3
    your solution worked , I put all the -D section within ""... it's really amazing that product so poorly engineered and ill-coded like Maven has managed to become so popular... – Pierluigi Vernetto Jul 22 '17 at 14:54
9

In my case, its because I copied pasted the command from the browser and it turned out that the dash was not the ASCII dash, just delete and type the dash again.

http://www.toptip.ca/2017/04/maven-most-weird-error-causing-failure.html

Mideel
  • 801
  • 7
  • 16
6

Totally true. When using PowerShell, you need to put quotes.
I run the command and put quotes around the parameters that have a dot, this works.
Instead of typing 1.4, you should type "1.4".

First time:

mvn archetype:generate 
   -DgroupId=com.mycompany.app 
   -DartifactId=my-app 
   -DarchetypeArtifactId=maven-archetype-quickstart 
   -DarchetypeVersion=1.4 -DinteractiveMode=false
Error:
[ERROR] The goal you specified requires a project to execute 
but there is no POM in this directory 
(C:\Users\jcrojas\OneDrive - Superfinanciera\Personal\Aprendizaje\Maven\test). 
Please verify you invoked Maven from the correct directory. -> [Help 1]

Second time:

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

...BUILD SUCCESS...

The command also works if it is run with the Windows command line, CMD.
In this case, the quotation marks are not necessary.

Zach
  • 539
  • 1
  • 4
  • 22
4

I was trying to install java jms-1.1.jar after downloading a copy from jboss repository.

Encountered exact same error and specifically on windows. Tried everything i.e. changed maven version / jdk version but no avail.

I was using the command below .

mvn install:install-file -DgroupId=javax.jms -DartifactId=jms -Dversion=1.1 -Dpackaging=jar -Dfile=jms-1.1.jar

Finally took a que from the comment in the main question and put every parameter value within double quotes

mvn install:install-file -DgroupId="javax.jms" -DartifactId="jms" -Dversion="1.1" -Dpackaging="jar" -Dfile="jms-1.1.jar"

This solved the problem. The issue seems very specific to windows environment. On ubuntu and mac the command works without any issues.

Gautam
  • 1,030
  • 13
  • 37
  • Some other answers and posts suggest to use a variation of the jar from apache but since the artifact ids are different its not really a solution. – Gautam Dec 27 '21 at 05:42
1

Changing mvn clean to mvn clean --file *.pom fixed this issue for me.

Matthias Braun
  • 32,039
  • 22
  • 142
  • 171
1

On Windows, I got this error when running under a non-administrator command prompt. When I ran this as administrator, the error went away.

tcb
  • 4,408
  • 5
  • 34
  • 51
  • Potentially you were running non-administrator under PowerShell and CMD for administrator so that the real difference was whether it was being run in PowerShell or not. – jpierson Dec 08 '20 at 15:54
1

1.create a lib folder in your project file,

2.copy your jarFiles to the lib folder

3.right click on to your jarFile go to build path>Add to build path (now your jar file is part of your refrerenced libraries )

4.open command prompt and navigate to your project directory and write

mvn install: install-file "-Dfile=<yourJarFileName>.jar" "-DgroupId=<yourGroupID>" "-DartifactId=<yourArtifactId>" "-Dversion=<yourVersion>" "-Dpackaging=jar" 

6.Rebuild your local repository index by opening in eclipse- go to window>show view>other>maven>maven Repositories. Right click on local Repositores and hit "RebuildIndex"

5.open your pom.xml file and add your dependency

    <dependency>
        <groupId><yourGroupID></groupId>
        <artifactId><yourArtifactId></artifactId>
        <version><yourVersion></version>
    </dependency>

and run

mvn clean
mvn compile 
mvn test 
CTester
  • 21
  • 4
  • I've been wondering how a simple maven command would be failing... I came up with your solution and voila! It worked! Nobody was writing the java params within the ", which was what I was missing. Thank you very much :) – joninx Sep 26 '16 at 14:21
0

I got this error suddenly in Netbeans (but it worked from the command line) and it turns out some other program had changed the default directory of the command prompt. And because Netbeans runs "cmd /c" when invoking maven, it starts in an incorrect directory.

Check out in Regedit the value for

HKEY_CURRENT_USER\Software\Microsoft\Command Processor\Autorun  

If it has been set, you probably should remove it to fix the problem. (1)

(I landed here when trying to resolve this issue, might not be 100% applicable to the current question - but might help others)

(1) Changing default startup directory for command prompt in Windows 7

Community
  • 1
  • 1
AtliB
  • 1,263
  • 1
  • 18
  • 30
0
  • The execution of maven command required pom.xml file that contains information about the project and configuration details used by Maven to build the project. It contains default values for most projects.

  • Make sure that porject should contains pom.xml at the root level.

0

Add the Jenkinsfile where the pom.xml file has present. Provide the directory path on dir('project-dir'),

Ex:

node {

    withMaven(maven:'maven') {

        stage('Checkout') {
            git url: 'http://xxxxxxx/gitlab/root/XXX.git', credentialsId: 'xxxxx', branch: 'xxx'
        }

        stage('Build') {

            **dir('project-dir') {**
                sh 'mvn clean install'

                def pom = readMavenPom file:'pom.xml'

                print pom.version
                env.version = pom.version
            }
        }
    }
}
0

There may be a problem with Maven path configuration, if you used unix-like Operator System.

step 1: create new file in path ~/.bash_profile

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home
CLASSPAHT=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
PATH=$JAVA_HOME/bin:$PATH:
export JAVA_HOME
export CLASSPATH
export PATH

step 2: shell run source ~/.bash_profile OR modify zsh config file(add new line: source ~/.bash_profile)

daidai21
  • 170
  • 2
  • 11
0

Just watch out for any spaces or errors in your arguments/command. The mvn error message may not be so descriptive but I have realised, usually spaces/omissions can also cause that error.

Arthur
  • 568
  • 7
  • 17
0

I just added the path to the pom.xml as such mvn -f path/to/pom.xml <goals> ... Worked great for me

0

There could be some special characters added to your command like the '-' U+2013 and U+002d

Please remove the special characters and try the command

user3865770
  • 405
  • 1
  • 6
  • 13
-1

"The goal you specified requires a project to execute": The answer is in your question. I faced the same issue. Run the "mvn command" within the project folder, Also make sure sure its a maven configured project and hence contains the "POM.xml" file and you should be good to go!

-1

Check for the name of the file, i.e pom.xml file is spelled correctly with proper file extension .xml.

Example for this error are

pom.ml pm.xl

Gani
  • 422
  • 1
  • 8
  • 16
-3

Please run it from the directory where POM.XML resides.

Sasiraj
  • 107
  • 1
  • 1
  • 9
    Downvoted because the `install:install-file` goal doesn't need to be (can't?) run on a project. It's used for manually installing an artifact into a repository. – Zoltán Aug 06 '14 at 15:31
  • I am trying to upload a zip file that has no Pom xml. downvoted – kazanaki Apr 28 '15 at 11:30