0

I'm getting the following error:

java.lang.NoSuchMethodError: 'com.google.common.collect.ImmutableMap com.google.common.collect.ImmutableMap$Builder.buildKeepingLast()'

My pom file looks like that:

<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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>de.kastenklicker</groupId>
  <artifactId>ActivateServer</artifactId>
  <version>0.0.1</version>

  <name>activateServer</name>
  <url>http://maven.apache.org</url>

  <properties>
    <maven.compiler.source>17</maven.compiler.source>
    <maven.compiler.target>17</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <repositories>
    <repository>
      <id>papermc</id>
      <url>https://repo.papermc.io/repository/maven-public/</url>
    </repository>
  </repositories>

  <dependencies>
    <dependency>
      <groupId>com.velocitypowered</groupId>
      <artifactId>velocity-api</artifactId>
      <version>3.2.0-SNAPSHOT</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.github.t9t.minecraft-rcon-client</groupId>
      <artifactId>minecraft-rcon-client</artifactId>
      <version>1.0.0</version>
      <scope>compile</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/com.google.cloud/google-cloud-compute -->
    <dependency>
      <groupId>com.google.cloud</groupId>
      <artifactId>google-cloud-compute</artifactId>
      <version>1.33.0</version>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>3.5.0</version>
        <configuration>
          <relocations>
            <relocation>
              <pattern>com.github.t9t.minecraft-rcon-client</pattern>
              <shadedPattern>de.kastenklicker.activeserver.com.github.t9t.minecraft-rcon-client</shadedPattern>
            </relocation>
            <relocation>
              <pattern>com.google.cloud</pattern>
              <shadedPattern>de.kastenklicker.activeserver.com.google.cloud</shadedPattern>
            </relocation>
          </relocations>
        </configuration>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <filters>
                <filter>
                  <artifact>*:*</artifact>
                  <excludes>
                    <exclude>META-INF/*.SF</exclude>
                    <exclude>META-INF/*.DSA</exclude>
                    <exclude>META-INF/*.RSA</exclude>
                  </excludes>
                </filter>
              </filters>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

What I tried so far: Adding google guava, like suggested in another question.

Including the class manual:

<artifactSet>
    <includes>
        <include>com.google.common.collect.ImmutableMap</include>
    </includes>
</artifactSet>

which results in:

java.lang.NoClassDefFoundError: com/google/auth/Credentials

and adding:

<include>com.google.auth.Credentials</include>

does nothing.

For context, the code I wrote is a plugin for the velocitypowered proxy and should start a Google Compute Engine, when a server connects to the proxy. My code works fine as standalone application.

I don't know any further, any help is appreciated. Thx

koque
  • 17
  • 2
  • 3
    it says NoSuchMethod, not NoSuchClass. Chances are, you have dependencies to several versions which contain that class, and one has that method, but the other doesn't – Stultuske Aug 25 '23 at 12:07

0 Answers0