views:

96

answers:

3

Is there a maven command that will verify that a WAR file is valid and not corrupt? Or is there some other program or technique to validate zip files? I'm on Ubuntu 9.10, so a linux solution is preferred.

On occasion, I end up with a corrupt WAR file after doing mvn clean and mvn install on my project. If I extract the WAR file to my hard drive, an error occurs and the file doesn't get extracted. I believe this happens when my system is in a low-memory condition, because this tends to happen only when lots of memory is in use. After rebooting, doing a mvn install always gives a valid WAR file.

Because this happens infrequently, I don't typically test the file by uncompressing it. I transfer the 50MB war file to my server and then restart Jetty with it as the root webapp. But when the file is corrupt, I get a java.util.zip.ZipException: invalid block type error.

So I'm looking for a quick way to validate the file as soon as mvn install is completed. Is there a maven command to do this? Any other ideas?

A: 

You could attempt to add a step which invokes the antrun plugin to do an <unzip> of the output WAR to a temporary file.

matt b
+1  A: 

You can use the dependency plugin for this. I'd consider implementing an integration test (start war in a servlet container and do a some smoke test) as well.

lexicore
I'll take a look at the dependency plugin. Thanks for the suggestion! I will eventually get integration tests going too, just not there yet.
Tauren
+1  A: 

Your corruption could be due to PLXCOMP-149. If you supress the included version of plexus-io that comes with the war plugin and replace it with the newly released 1.0, your problems just might go away.

I know I'm not answering your question, but I might solve your problem. Add a dependency to

<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-io</artifactId>
<version>1.0</version>

To your war plugin's plugin section.

krosenvold
Thanks, I'll give this a try.
Tauren
And do tell me if it helps ;)
krosenvold