Maven ... Failed to clean up the project: could not delete .. \ org.ow2.util.asm-asm-tree-3.1.jar

I am using the STS (spring) + maven toolkit.

Every time I run my application using maven-clean , I see the following error:

 [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building hhsystem ui 1.0.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ ui --- [INFO] Deleting C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\target [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.471s [INFO] Finished at: Mon Oct 21 12:34:33 MSK 2013 [INFO] Final Memory: 2M/90M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.4.1:clean (default-clean) on project ui: Failed to clean project: Failed to delete C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\target\org.ow2.util.asm-asm-tree-3.1.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 

I need to close STS and go to C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\target and delete org.ow2.util.asm-asm-tree-3.1.jar

After starting STS, it works again, but it's a hassle.

Can you help me with this problem?

UPDATE
for Kalatoka L.

I run maven-clean from this state:

STS screen shot

I see the same behavior from the command line as from the eclipse plugin

If I watch the unlock when STS starts, I see

unlocker screen shot :

+62
java spring eclipse spring-tool-suite maven
Oct 21 '13 at 8:39
source share
20 answers

Stop your server before starting the cleanup.

Server stop

You can stop the server from the Servers view.

To stop the server:

  • In the Servers view ( Window> Show view> Other> Server> Servers> OK ), select the server you want to stop.
  • Click the Stop Server icon this in the toolbar. In the Servers view, the server status changes to Stopped.
  • If for some reason the server cannot stop, you can complete the following:

    but. Switch to the debugging perspective.

    b. In the Process view, select the server process that you want to stop.

    from. Click Finish This is an image of the Terminate toolbar icon.

Note. . When the server shuts down, the server process ends and the server will not go through the usual shutdown procedure, for example, calling the destroy () method on the servlet.

Source: Eclipse Help

+48
Oct 21 '13 at 8:46
source share

You can also try trying -Dmaven.clean.failOnError=false (from the Maven Frequently Asked Questions )

+32
Sep 19 '14 at 6:34
source share

Delete the java.exe process in the Task Manager and run mvn clean install.It worked for me.

+16
Jun 14 '17 at 14:15
source share

Your problem is that the running process in STS uses the files located in your target directory when executing the mvn clean command. Maven will not be able to delete these files (as other processes are still accessing them) and thus fail with this error.

Try stopping all processes (tests, servers, applications) from within STS before running Maven console commands. Look: this behavior can also occur if STS cleans up projects and, therefore, recompiles sources and does not start the process.

+13
Oct 21 '13 at 8:56
source share

Perhaps there are many processes that use source compilation, may be a server, an old maven command, or an IDE. Of course, stop all processes, stop the server, and then run maven again. If the problem persists, you should close the java.exe process.

Hello!

+9
Aug 22 '16 at 15:06
source share

Try disabling Project-> Build Automatically.

As Scorpio said, a process works there that blocked a file somewhere.

I have a large multi-module maven project that regularly fails in its pure form, and this resolves this for me. I turn Build Automatically on again when done.

+6
Jan 08 '16 at 12:03
source share

Close the target folder and its file that you opened before mvn clean

+6
Feb 03 '17 at 7:25
source share

Summary: Use an external script (batch file) that: a) stops the server and b) unlocks the .jar file before running maven-clean.

Steps:

  • Bind maven-antrun-plugin: start the target in the mvn clean pre-cleaned phase. See how to do it here.

  • See how to use the antrun plugin to run an external batch file on Windows here: sblundy answer to "Run an external process . " Call this file unlock_handles.bat

  • Use the Sysinternals handle utility to download the link in the pre_clean.bat file to: a) stop Tomcat and b) unlock the .jar file. handle -c and handle -p .

Phew! This is a little work, but it will reliably automate the process for you, so you need to do it manually every time!




OK, here's an example version of unlock_handles.bat with proof of concept:

 REM "Use handle.exe to figure out the process id and handle ids, parse the output, then close the handle (again using handle.exe)" cd "C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\target" "c:/Program Files/Process Explorer/handle.exe" -p java.exe "C:\Users\Nikolay_Tkachev\workspace\HHSystem\UI\target" > handles.txt @echo "O====== Going to unlock all the below file handles! =======O" FOR /F "tokens=1-26 delims=: " %a in (handles.txt) DO @echo %h FOR /F "tokens=1-26 delims=: " %a in (handles.txt) DO handle -p %c -c %f -y 

Of course, you must change the path of the handle.exe Sysinternals file before you try.

+5
Oct 23 '13 at 17:27
source share

I have the same problem and this

 mvn clean install -U 

bug fixed.

+4
Jun 06 '16 at 7:36
source share

If all steps (in existing answers) do not work, just close the eclipse and close eclipse again.

+3
Nov 21 '17 at 4:32
source share

For Linux users: a possible solution.

A build error due to the error β€œFailed to delete <any-file-or-folder>” will occur if there is a chance that data access, available only to the root user , is provided only by the normal -user .

Fix: enter the ll command to display a file that cannot be deleted if root access is granted for the file, change it to a regular user:

sudo chown -R username: username file_name

Later try maven clean and build.

+1
May 23 '14 at 12:54
source share

I had a similar problem. I used to use Maven 3 to create a project. After switching to maven 2, I had the error above.

Solved it by switching to Maven 3.

+1
Mar 21 '16 at 23:42 on
source share

I solved mine by doing:

  • mvn clean
  • install MVN
  • mvn clean install

For some reason this worked for me. Good luck !!

+1
Feb 14 '18 at 20:14
source share

If you block org.ow2.util.asm-asm-tree-3.1.jar and run eclipse, the log shows who could not block the file. The same code line that cannot lock the file will not release the lock.

0
Jul 07 '14 at
source share

In the pre-cleaning phase, I run the Maven Unlocker program. This program unlocks all files and directory for any program.

I do this with maven-antrun-plugin and only on windows systems

 <profile> <activation> <os> <family>windows</family> </os> </activation> <build> <plugins> <plugin> <artifactId>maven-antrun-plugin</artifactId> <version>1.8</version> <executions> <execution> <phase>pre-clean</phase> <configuration> <tasks> <exec dir="${project.build.directory}" executable="cmd" failonerror="false"> <arg value="Unlocker.exe" /> <arg value="/S" /> </exec> </tasks> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </profile> 
0
Sep 10 '15 at 11:04
source share

Maven complains if you do not have administrator rights in the destination folder. Check if the administrator has the right to delete this folder.

enter image description here

0
May 9 '17 at 1:01
source share

Delete the target file and close the code editor, then open it again, it will certainly work. This one is temporarily looking for a permanent.

0
Dec 18 '18 at 13:09
source share

Please close all browser tabs. And the next time you try to load the war from a place other than the destination folder.

0
Jan 25 '19 at 11:42
source share

If you encounter this error in an IDE such as Eclipse or IntelliJ, you may have one or more debug windows open and paused at the breakpoint. Stop them.

0
Sep 10 '19 at 16:29
source share

I had this problem when trying to call mvn clean install after sending a colleague an email with .jar from / target via Microsoft Outlook.

I had to close Microsoft Outlook to invoke mvn clean install .

-one
May 09 '18 at 15:32
source share



All Articles