Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Maven – exec-maven-plugin – CreateProcess error=2, The system cannot find the file specified

I am using this code to upload a JAR file to a Server right after the Install phase:

  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>3.0.0</version>
    <executions>
      <execution>
        <id>server-deployment</id>
        <phase>install</phase>
        <goals>
          <goal>exec</goal>
        </goals>
      </execution>
    </executions>
    <configuration>
      <executable>D:\my-folder\pscp.exe -r -i D:\my-folder-conf\user.ppk D:\my-folder-jar\file-1.1.0.jar ubuntu@X.XX.XX.XXX:/usr/local/folder1/jar/file-1.1.0.jar</executable>
    </configuration>
  </plugin>

The command:

D:\my-folder\pscp.exe -r -i D:\my-folder-conf\user.ppk D:\my-folder-jar\file-1.1.0.jar ubuntu@X.XX.XX.XXX:/usr/local/folder1/jar/file-1.1.0.jar

Works from Windows Console normally and the file is uploaded, but when I execute the very same command with the exec-maven-plugin, it fails with the message: CreateProcess error=2, The system cannot find the file specified. If I am providing full paths and extensions to all files, how does this happen? Is there any solution for this=

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Solution:

I ended up using the approach of @xerx593, thanks for your help, here bellow is the final solution:

<configuration>
  <executable>D:\my-folder\pscp.exe</executable>
  <arguments>
    <argument>-r</argument>        
    <argument>-i</argument>      
    <argument>D:\my-folder-conf\user.ppk</argument>       
    <argument>${project.build.directory}/${project.build.finalName}.jar</argument> 
    <argument>ubuntu@X.XX.XX.XXX:/usr/local/folder1/jar/${project.build.finalName}.jar</argument>  
  </arguments>
</configuration>

>Solution :

Please try:

    <configuration>
      <executable>D:\my-folder\pscp.exe</executable>
      <arguments>
        <argument>-r</argument>        
        <argument>-i</argument>      
        <argument>D:\my-folder-conf\user.ppk</argument>       
        <argument>D:\my-folder-jar\file-1.1.0.jar</argument> 
        <argument>ubuntu@X.XX.XX.XXX:/usr/local/folder1/jar/file-1.1.0.jar</argument>  
      </arguments>
    </configuration>

…as documented (& shown) instead.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading