Eclipse: The project was not built due to error

Robert picture Robert · Nov 26, 2012 · Viewed 16.2k times · Source

I get this error message whenever I create new Spring MVC projects in Eclipse STS.

The project was not built due to "Error deleting resource '/ProjectName/target/classes/log4j.xml' from the workspace tree." Fix the problem, then try refreshing this project and building it since it may be inconsistent.

Why is this happening? I haven't changed anything and the file located at classes\log4j.xmlexist on the file system. When I try to import the files, Eclipse tells me that I can't because the source is already existing in the project (even though it's telling me it has been deleted).

Answer

Vaishak Suresh picture Vaishak Suresh · Nov 26, 2012

This may be because the file/folder is locked and eclipse could not delete it. Try re-starting Eclipse. If that doesn't work, manually delete the files. Since it is in classes folder, it will get re-created when you build.

If all else fails, try restarting the machine.