guavawildfly-10immutable-collections

java.lang.NoSuchMethodError: com.google.common.collect.ImmutableSet.builder()Lcom/google/common/collect/ImmutableSet$Builder


I'm getting this error continuously

Failed to execute goal deploy: {"WFLYCTL0062: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-1" => {"WFLYCTL0080: Failed services" => {"jboss.undertow.deployment.default-server.default-host./" => "org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./: java.lang.NoSuchMethodError: com.google.common.collect.ImmutableSet.builder()Lcom/google/common/collect/ImmutableSet$Builder;

[ERROR] Caused by: java.lang.NoSuchMethodError: com.google.common.collect.ImmutableSet.builder()Lcom/google/common/collect/ImmutableSet$Builder;"},"WFLYCTL0412: Required services that are not installed:" => ["jboss.undertow.deployment.default-server.default-host./"],"WFLYCTL0180: Services with missing/unavailable dependencies" => undefined}}}

And here is what I have in my pom.xml

    <dependency>
        <groupId>com.google.inject</groupId>
        <artifactId>guice</artifactId>
        <version>5.0.1</version>
    </dependency>
    <dependency>
        <groupId>com.google.inject.extensions</groupId>
        <artifactId>guice-assistedinject</artifactId>
        <version>5.0.1</version>
    </dependency>

    <dependency>
        <groupId>com.google.inject.extensions</groupId>
        <artifactId>guice-multibindings</artifactId>
        <version>4.2.3</version>
    </dependency>

    <dependency>
        <groupId>io.github.bonigarcia</groupId>
        <artifactId>webdrivermanager</artifactId>
        <version>5.1.0</version>
    </dependency>

    <dependency>
        <groupId>com.google.inject.extensions</groupId>
        <artifactId>guice-servlet</artifactId>
        <version>5.0.1</version>
    </dependency>
    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>31.0.1-jre</version>
    </dependency>

Solution

  • Found the solution for this. Checked all the dependencies using mvn dependency:tree

    enter image description here

    And then found that org.drools library is there and it is containing google-collections associated with that. But now google-collections is deprecated, we can get the same by using com.google.guava. So excluded the google-collections from drools dependency, So it worked for me. Added this into the pom.xml

    <dependency>
    <groupId>org.drools</groupId>
    <artifactId>drools-ant</artifactId>
    <version>5.1.1</version>
    <exclusions>
        <exclusion>
            <groupId>com.google.collections</groupId>
            <artifactId>google-collections</artifactId>
        </exclusion>
    </exclusions>