Java does not natively support having multiple jvms modify the same file/folder. Many Java programs will try to do it, but a lot of times they will run into random problems. This is similar to race conditions inside of a single JVM.
What does this have to do with Maven? Maven uses a local repository. Before building your code, Maven will download your project's dependencies into your local repository. This works great when building your project on a desktop. It does not work well when you have multiple copy-dependency goals running at the same time. Why would you do that? You need to extract your artifacts when you deploy to your Tomcat or Webshere JVM. In a large organization, you will probably have multiple extracts occur in at the same time. Welcome to random local repository corruption!
How do we prevent this corruption? The first thing you can do is use a different local repository for each extraction JVM. Your mileage may vary but I noticed other problems with that. I may go further into detail of those problems in a future post. The only foolproof way I found was to create a new temporary local repository at the start of every extract. Yes this does make the extract much longer because Maven has to redownload the world at the start of every extract. That was the best I could do, though.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.