Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: com/google/common/collect/Streams

351 views Asked by At

We are building executable JAR from my project using springboot. basically, application is fetching the value based on keys from ETCD cluster using java client

here is the env.

Springboot : 3.1.5 java : 17

Maven : 3.9.0

pom.xml with all dependencies is is below

<dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope> 
             <exclusions>
              <exclusion>
            <groupId>com.vaadin.external.google</groupId>
            <artifactId>android-json</artifactId>
            </exclusion>
          </exclusions>
        </dependency>
         <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 -->
<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger2</artifactId>
    <version>2.9.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui -->
<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger-ui</artifactId>
    <version>2.9.2</version>
</dependency>
<dependency>
  <groupId>io.springfox</groupId>
  <artifactId>springfox-schema</artifactId>
  <version>2.9.2</version>
</dependency>

<dependency>
    <groupId>org.netbeans.external</groupId>
    <artifactId>org-eclipse-jgit</artifactId>
    <version>RELEASE180</version>
</dependency>
    <dependency>
    <groupId>io.kubernetes</groupId>
    <artifactId>client-java</artifactId>
    <version>15.0.1</version>
</dependency>

 <dependency>
    <groupId>org.json</groupId>
    <artifactId>json</artifactId>
    <version>20230227</version>
</dependency>

<dependency>  
<groupId>org.springframework.boot</groupId>  
<artifactId>spring-boot-starter-security</artifactId>  
</dependency>

 <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
  </dependency>
  
  <dependency>
  <groupId>io.etcd</groupId>
  <artifactId>jetcd-core</artifactId>
  <version>0.7.5</version>
</dependency>
    </dependencies>

The issue seems in below code . in this code , we are fetching the value of key : "admin"

  String cluster0 = "http://<ip>:<port>";
        ClientBuilder clientBuilder = Client.builder()
                .user(ByteSequence.from("root".getBytes()))
                .password(ByteSequence.from("pass".getBytes()))
                .endpoints(cluster0);
        Client client = clientBuilder.build();
        KV kvClient = client.getKVClient();
        
        CompletableFuture<GetResponse> getFuture = kvClient.get("admin");
        GetResponse response = getFuture.get();

         System.out.println(response.toString());
        

and the error is

Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: com/google/common/collect/Streams

I checked the classpath and seems all fine . there is some issue with maven dependency I guess . I deleted all plugins from maven local repository and downloaded fresh one . still issue

Please suggest

1

There are 1 answers

0
user2315104 On

This is resolved by adding below dependency in Maven POM. The class mentioned in the error is present in below lib. Thanks

<dependency>
    <groupId>com.google.guava</groupId>
    <artifactId>guava</artifactId>
    <version>32.1.3-jre</version>
</dependency>