This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 197306 - Maven JavaEE web projects cannot be reliably cleaned: "Failed to clean project: Failed to delete [path-to-build-dir]\lib"
Summary: Maven JavaEE web projects cannot be reliably cleaned: "Failed to clean projec...
Status: RESOLVED DUPLICATE of bug 195195
Alias: None
Product: projects
Classification: Unclassified
Component: Maven (show other bugs)
Version: 7.0
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Jesse Glick
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-01 06:11 UTC by ringerc
Modified: 2011-04-04 21:51 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ringerc 2011-04-01 06:11:30 UTC

    
Comment 1 ringerc 2011-04-01 06:12:17 UTC
Sorry, accidentally submitted with enter key before the report was ready. Details following shortly.

(Surprising that BugZilla doesn't query you if the report has a blank body!)
Comment 2 ringerc 2011-04-01 06:21:46 UTC
Maven can't delete the target/ directory while file handles are open to jars within it, and netbeans.exe keeps a handle to javaee-endorsed-api-6.0.jar open when working with maven web projects, so cleaning of these projects fails. 

The workaround is to quit NetBeans and delete the "target" directory manually before relaunching NetBeans.

 Detail:

When creating a Maven-based Java EE Web project under NetBeans, the the Maven web project archetype automatically adds a deployment command to copy javaee-endorsed-api-6.0.jar to ${project.build.directory}/endorsed . The purpose of this appears to be to fix the invalid definition of @Resource shipped in Java SE 6, which is lacking a 'lookup' attribute. The existence of this jar in the endorsed directory is necessary for the proper function of a Java EE 6 web project that uses @Resource injection.

When the project is opened by NetBeans, it will open a handle to javaee-endorsed-api-6.0.jar . This handle is kept open by netbeans.exe even when the web app being developed is not running.

Because Maven cleans a project by deleting the 'target' directory, and because Windows can't unlink() a file that has open handles to it, NetBeans on Windows will often fail to clean a Maven web application project with an error like:

Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.4.1:clean (default-clean) on project classads-webui: Failed to clean project: Failed to delete C:\Users\Craig\Developer\classads\webui\target\classads-webui-1.0-SNAPSHOT\WEB-INF\lib -> [Help 1]

It's an ugly situation. The best fix would be to fix the JDK so that a correct version of the @Resource annotation and the other fixes in javaee-endorsed-api-6.0.jar are shipped and it's beyond me why Oracle hasn't done so by now. Failing that, NetBeans would need to close the endorsed jar before cleaning the project, then re-open it.
Comment 3 ringerc 2011-04-01 06:40:52 UTC
Whoops, this is a duplicate of: http://netbeans.org/bugzilla/show_bug.cgi?id=195195
Comment 4 Jesse Glick 2011-04-04 21:51:09 UTC
Right, fixed (I hope!) by parsing endorsed APIs from the local repository rather than from the copy in the target dir (which is then used only by Maven builds and not the IDE directly).

*** This bug has been marked as a duplicate of bug 195195 ***