问题
I'm working on a pretty complex project (Java / Spring / Maven multi-module) with WAR overlays in Eclipse Indigo Java EE (heavily using m2eclipse) on Ubuntu 11.10 / 64bit
All good till this morning: I cannot clean / publish to tomcat anymore:
Publishing failed
Could not delete <directory> May be locked by another process.
I can easily delete these files by hand (but still tomcat cannot publish), and I cannot find out which process might be locking it (linux: lsof <directory>
)
I tried a sh..load of things in Eclipse: removed projects (works then), added again (same issue), deleted server config, deleted tomcat config, updated eclipse, started eclipse with -clean, moved server directory out of the plugin folder, rolled back the project to a branch that definitely worked the other day...
As as said: everything was good till yesterday. I found this issues here, with someone having the same problem lately. Googling around doesn't reveal much. Some guys had similar issues which they "fixed" by heavily deleting / recreating server configs. Tried that at least 10 times.
Same issues on a colleague's linux box - he set up his system yesterday and ran into it right away.
I found this bug-report of m2e-wtp which might be related.
Update: I'm pretty sure its the combination of WAR overlay and this build of Maven Integration for WTP: 0.15.1.20120208-1300 Actually trying to downgrade to 0.14...
回答1:
It was the plugin in combination with a WAR overlay. Fixed it with this nightly build: http://download.jboss.org/jbosstools/builds/staging/m2eclipse-wtp-e37/all/repo/ (version 0.16.xxx)
I saw that this URL http://download.jboss.org/jbosstools/builds/staging/m2eclipse-wtp-staging/all/repo/ provides version 15.2.xxx, which might be a better (first) try, as I have no idea what other issues will pop up with 16.xxx nightly...
回答2:
I see no simple solution. What you can try:
Create an Eclipse launch config so you can debug Eclipse from itself. Look into the sources of WTP to find out where the error message comes from and set a breakpoint.
Get a copy of the plugin and change the code to list the files in the directory when it can't delete them. My gut feeling is that some process (like the resource copied from m2e) is copying files into the directory while some other plugin tries to redeploy.
That said: I've given up on Tomcat and WAR deployment. It's too slow and too error prone. For all my projects, I use an embedded Jetty server which I run from within Eclipse. Reasons:
- The Jetty server gets the same classpath as the compiler. There is no need to waste my time copying stuff around.
- It starts much faster (Jetty: 5s, Tomcat with deployment: 45s)
- The Jetty server is a normal Java application, so I don't have to set up remote debugging
- I can run the same server from a unit test
- I can configure Jetty when it should restart
- No messing with XML config files
回答3:
this worked for me :
1. go to server tab.
2. Double click on tomcat server.
3. in the tomcat config window check server modules without publishing
4. start the server. (this will replace your project deployed in tomcat)
5. stop the server.
6. in the tomcat config window Uncheck server modules without publishing.
7. start the server.
来源:https://stackoverflow.com/questions/9615284/eclipse-wtp-m2eclipse-can-neither-clean-nor-publish-to-tomcat