Could not initialize class org.apache.maven.plugin.war.util.WebappStructureSerializer in pom.xml

Could not initialize class org.apache.maven.plugin.war.util.WebappStructureSerializer in pom.xml eclipse or sts. you might be facing this error in pom.xml. while creating a new project or importing any existing project into eclipse or STS.

Maven error “Could not initialize class org.apache.maven.plugin.war.util.WebappStructureSerializer in pom.xml”

It’s showing due to the maven and java version incompatibility. To solve this error add the below plugin into pom.xml. Update the maven or build the project. It will work fine.

  <pluginManagement>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-war-plugin</artifactId>
      <version>3.3.2</version>
    </plugin>
  </plugins>
</pluginManagement>

Add the above plugin between the <build></build> tag into pom.xml. below is the complete source code of pom.xml.

Pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com</groupId>
  <artifactId>Demo</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>Demo Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <finalName>Demo</finalName>
    <pluginManagement>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-war-plugin</artifactId>
      <version>3.3.2</version>
    </plugin>
  </plugins>
</pluginManagement>
  </build>
</project>