views:

181

answers:

2

I'm using MyEclipse 8.0 to develop a Spring Batch project. Recently, I added MySQL to the database explorer perspective and now when I try to do "mvn clean" on my project, it fails because it can't delete the mysql-connector-java-5.1.6.jar from the target lib folder. I've tried manually deleting this jar, but I get that popup that says it's being used by another person or program. So far, the only way I've found to continue is to close MyEclipse every time I need to run another test. This problem doesn't occur with any other database I'm using (DB2).

A: 

Well, good or bad, the fact is that the file is locked by another process and the delete fails. When configuring the database explorer, try to use the MySQL jar from your local repository instead of the one in the target directory. This should solve your problem.

Pascal Thivent
Problem is, Maven keeps putting or leaving that jar in the target directory after each test; but I have no idea why or how. Maven seems to get rid of the DB2 jars after each test, but not the MySQL.
Mike GH
@Mike Maybe I'm missing something but my understanding of your question is that the database explorer is locking the mysql jar, not maven. But I may be wrong.
Pascal Thivent
Hard to say ... wasn't sure where to ask about this initially. After a test runs, the target lib contains all the Maven dependency jars. "Clean" successfully removes everything until it encounters the one for MySQL. Perhaps this is a question for MyEclipse support. Thx.
Mike GH
@Mike well, if you have to close MyEclipse and if this doesn't happen on the command line, then you have your answer :)
Pascal Thivent
Took your point and changed the location of jar used in database perspective for MySQL, but this did not seem to solve the problem.
Mike GH
@Mike Hmm... Do things work when you run maven on the command line (with MyEclipse closed)?
Pascal Thivent
Finally resolved this problem by pointing to a MySQL jar outside of the MyEclipse workspace. Thanks, everybody!
Mike GH
+1  A: 

Sometimes windows explorer doesn't release file locks on things in the target directory. Try using Process Explorer to see what has a lock on the file. You can then use it to release the lock if it's something that doesn't matter. After that, you mvn clean will run fine.

Shayan