Maven Build Problem with JDK 7

I recently upgraded my system from Java 6 to Java 7. Over all I’m really pleased with the improvement I’m seeing from Java 7 but the upgrade has come with a little cost. For some reason I’m getting a failure in NetBeans when I try to deploy one of the web applications that I’m working on.

The error message I see is:

message             : Cannot construct org.apache.maven.plugin.war.util.WebappStructure as it does not have a no-args constructor
cause-exception     : com.thoughtworks.xstream.converters.reflection.ObjectAccessException
cause-message       : Cannot construct org.apache.maven.plugin.war.util.WebappStructure as it does not have a no-args constructor
class               : org.apache.maven.plugin.war.util.WebappStructure
required-type       : org.apache.maven.plugin.war.util.WebappStructure
path                : /webapp-structure
line number         : 1

I’ve seen a few reports of this problem but they were mostly several years old and no one seemed to have a reliable solution. The closest I can find is this post about an Apache project that won’t build. It would seem that the problem is with the maven-war-plugin and a fix has been made. Until I have time to investigate how to upgrade the plugin the quickest work around seems to be to run a clean before a deploy.

Update

Ok, I feel a bit silly now. It was, as many things are with maven, trivially easy to properly fix the problem. Just pop open the pom file and find the mavan-war-plugin plugin and then upgrade it to version 2.1.1. If you are using NetBeans it should auto-complete the version if you just delete what is currently in place.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.1.1</version>
    <configuration>
        <failOnMissingWebXml>false</failOnMissingWebXml>
    </configuration>
</plugin>