Search code examples
javaeclipsemaven

Eclipse maven exception java.lang.ExceptionInInitializerError: Cannot access defaults field of Properties [in thread "Worker-27: Building"]


I have just updated eclipse to Version: 2022-06 (4.24.0), and have the next exception in problems view (in pom.xml file):

Exception java.lang.ExceptionInInitializerError: Cannot access defaults field of Properties [in thread "Worker-27: Building"]

The pom.xml file contains:

<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    ...
  </parent>
  <artifactId>xxxx</artifactId>
  <packaging>war</packaging>
  <properties>
    <maven.compiler.target>1.8</maven.compiler.target>
    <maven.compiler.source>1.8</maven.compiler.source>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  <dependencies>
    ...
  </dependencies>
  <repositories>
    <repository>
      ...
    </repository>
  </repositories>
  <build>
    <finalName>xxxx</finalName>
    <plugins>
      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <configuration>
          <webXml>WebContent\WEB-INF\web.xml</webXml>
          <encoding>UTF-8</encoding>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

No problems when generating maven artifactory.

Any idea how to avoid these error?


Solution

  • the solution is modify maven-war-plugin adding version 3.3.2:

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>3.3.2</version>
        <configuration>
          <webXml>WebContent\WEB-INF\web.xml</webXml>
          <encoding>UTF-8</encoding>
        </configuration>
      </plugin>
    

    thanks