Maven - Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.4.1:clean
Asked Answered
F

22

18

I've a problem with the following dependency in my pom.xml where org.springframework.version = 3.1.0.RELEASE:

<!-- Spring MVC framework -->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webmvc</artifactId>
    <version>${org.springframework.version}</version>
</dependency>

When I execute the command line 'mvn clean install', I've the following error :

 [INFO] BUILD FAILURE
 [INFO] ------------------------------------------------------------------------
 [INFO] Total time: 1.052s
 [INFO] Finished at: Sat Dec 07 15:49:04 CET 2013
 [INFO] Final Memory: 4M/15M
 [INFO] ------------------------------------------------------------------------
 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.4.1:clean (default-clean) on project myGoogleAppEngine: Failed to clean project: Failed to delete C:\EclipseProjects\myGoogleAppEngine\target\myGoogleAppEngine-0.0.1-SNAPSHOT\WEB-INF\lib\spring-webmvc-3.1.0.RELEASE.jar -> [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/MojoExecutionException

By seeing on http://mvnrepository.com/artifact/org.springframework/spring-webmvc/3.1.0.RELEASE , there aren't any errors in my dependency.

Do you have any solutions?

Foucault answered 7/12, 2013 at 15:6 Comment(1)
Try linkMoody
S
28

Failed to delete C:\EclipseProjects\myGoogleAppEngine\target\myGoogleAppEngine-0.0.1-SNAPSHOT\WEB-INF\lib\spring-webmvc-3.1.0.RELEASE.jar

Because of the path C:\EclipseProjects i guess you have eclipse running on that project. If you application runs, you cannot clean the output, because it may be in use.

Stop the application and maybe eclipse and try again.

Severalty answered 7/12, 2013 at 15:37 Comment(5)
I always have the same problemFoucault
I think there is a running process, which has the jar loaded.Severalty
Glassfish server in my case. Not only you have to undeploy your applications but stop the server as well.Tessatessellate
In my case also it is GlassFish server. Have to stop it as well before doing clean and build.Raja
I tried all the solutions but nothing is worked in Client VDI,facing same issue from day 1 of EclipseExclude
I
19

Delete the java.exe process in Task Manager and re-execute.It worked for me.

Infusive answered 8/6, 2016 at 8:16 Comment(2)
In my case it was just try to restart the IDE (Eclipse), like in the "IT Crowd" TV show.Reverberate
A restart of IntelliJ worked for meSuburban
R
7

Make sure that your permissions are correct on the folder.As i faced same problem and after changing the ownership of the folder and files the problem was solved.

Roping answered 9/5, 2014 at 14:47 Comment(0)
A
6
  • Solution 1: Sometimes the build fails because, the target folder cannot be deleted. (It might be open in the backend due to the previous builds.)

    -> Open Task Manager

    -> In the Process tab

    -> Do "End Process" for the running "java.exe" processess

  • Solution 2:

    -> Restart eclipse

    -> Perform Maven Build with command : clean install -DSkipTests

Applicative answered 4/2, 2020 at 5:24 Comment(0)
R
5

Kill the "Java (TM)" process from processes in your computer. Re-run the mvn command. It should work now.

Ruthenious answered 28/3, 2016 at 12:57 Comment(0)
T
4

Try changing the permissions on the workspace folder. Make sure you have sufficient permissions to delete files in this folder. I faced the same problem and when i provided full control over the project folder (changing windows security permissions), it worked fine for me.

Just to update, this morning it again started giving the same error even when i have given all the permissions. So i tried to delete the particular file (pointed in the error logs) manually to find out what's exactly the problem.

I got the error "can not delete file because it's in use by Java TM SE". So the file was being used by java process due to which eclipse was not able to delete it.

I closed the java process from task manager and after that it worked fine. Although its kinda hectic to close the java process every time I need to execute my project, its the working solution right now for me.

Trichinosis answered 9/6, 2014 at 7:14 Comment(0)
G
4

Reason and solution-

Everything happens for a reason :)

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:3.1.0:clean (default-clean) on project

  • The reason of this problem is that the target folder is already in use. That means any jar or any war or any application is using that target folder

Solution- 1) Check the war and jar (also check jar if any running in background), terminate it.

2) if u have opened command prompt (cmd), and are using that path to execute the jar, close it or change the path in cmd. This was the reason in my case. Do check this.

Once u do this , u would be able to delete the contents of the target folder and and can also perform maven clean and maven install.

Grenier answered 29/4, 2019 at 12:35 Comment(0)
P
3

On Windows, I got "Unable to delete directory". What's wrong? For instance, clean could fail if you already have opened a command line with target as the current dir. Windows locks some ressources and you need to close the handles on these ressources.

This works for me.

Patrick answered 11/6, 2020 at 7:13 Comment(0)
L
1

if you run a server instance, stop it for the time of build process. worked for me.

Lieabed answered 6/6, 2014 at 9:58 Comment(0)
V
0

In my case, it was Subversion, TortoiseSVN clinging to those files, so I just clicked on SVN in the Eclipse menu and then disconnect. Worked for me.

Vitriolize answered 7/7, 2014 at 12:28 Comment(0)
A
0

If you open the directory which it is trying to delete then also you will face same error so first close the folder.

Arianearianie answered 27/1, 2015 at 12:48 Comment(0)
M
0

In my case I changed the owner of all the files and it worked.

sudo chown -R anuruddha *
Mitten answered 1/4, 2015 at 10:34 Comment(1)
User is running on Windows not a *NIX environmentChorea
T
0

For me it worked by closing the Eclipse and using the command line to build the project. Seems like Eclipse had taken a lock on the files.

Terhune answered 3/12, 2015 at 4:46 Comment(0)
H
0

you may need to check whether the settings.xml file is correct. such as user name, password, third party url.

Hilaire answered 29/9, 2017 at 2:1 Comment(0)
P
0

I've noticed that sometimes eclipse somehow picks up some of the jars and keeps a lock on them (in Windows only) and when you try to do mvn clean it says:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.2:clean (default-clean) on project

The only solution so far is to close eclipse and run the mvn build again.

And these are random jars - it can pick up anything it wants... Why that happens is a mystery to me. Probably eclipse opens the jars when you do Type Search or Resource Search and forgets to close them / release the file handlers..

Pengelly answered 8/8, 2018 at 10:50 Comment(0)
G
0

If you have opened the command prompt(cmd) to run the jar on current folder,then the error will come as above.so close the command prompt and try maven clean and install,it will work definitely.

Gong answered 3/10, 2019 at 15:42 Comment(0)
B
0

For IntelliJ users,

1. File -> Invalidate your cache/restart the ide 
2. clean install -DSkipTests
Bateman answered 7/2, 2020 at 16:26 Comment(0)
I
0

In my case in my background I was inside the folder from command prompt after closing the command prompt. I was able to run the maven clean command.

Ineludible answered 9/12, 2021 at 17:28 Comment(0)
R
0

For me clearing the previous maven tasks worked. enter image description here

After clearing this, from eclipse project properties > run as > maven > clean followed by try maven build.

Best luck!

Rudin answered 19/6, 2022 at 23:43 Comment(0)
P
0

For me manually deleting the files in target folder using sudo worked. It's the need for root permission to delete files in the target folder.

Prizewinner answered 13/9, 2022 at 4:16 Comment(0)
A
0

If you were doing some changes in maven build part in pom.xml. And you have a cmd window opened before making those changes. Then close / kill cmd process first, then rerun Clean/Build and it succeeds.

Activity answered 16/8, 2023 at 11:15 Comment(0)
L
0

you just have to change this file pom in the proyect with the actually version of jdk.

    <maven.compiler.source>21</maven.compiler.source>
    <maven.compiler.target>21</maven.compiler.target>
Licastro answered 10/6 at 1:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.