java.lang.NoSuchMethodError: okio.BufferedSource.rangeEquals(JLokio/ByteString;)Z

10,309

Solution 1

BufferedSource 

is in okio project version 1.13.0. Both dependencies com.squareup.retrofit2 and com.squareup.okhttp3 use this version. Also in this version this method is included. Version-wise it looks okay.

Local Environemnt

Now make sure to clear your maven repository. Maybe an old version got hung up somewhere. After that do a maven update project and a clean install.

Tomcat Environment

If this is happening in your tomcat make also sure to delete the work/Catalina/localhost/ folder, because sometimes things could be cached there.

Solution 2

I experienced a similar issue while executing a MapReduce job via YARN. In my case, an existing downgraded okio version was present which was overriding the external libraries of the application. I changed it to okio 1.13.0 and the issue was fixed.

It was this location for me:

/home/vagrant/bigdata/hadoop/share/hadoop/hdfs/lib

Share:
10,309
Paras
Author by

Paras

Seeking for helpers.

Updated on June 26, 2022

Comments

  • Paras
    Paras about 2 years

    I am integrating Outlook API and for making HTTP Calls I am using Retrofit version 2.3.0 and okHttp3 version 3.9.1. However when I'm making an HTTP Call, for example :

     // Create a logging interceptor to log request and responses
      HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
      interceptor.setLevel( HttpLoggingInterceptor.Level.BODY );
    
      OkHttpClient client = new OkHttpClient.Builder().addInterceptor( interceptor ).build();
    
      // Create and configure the Retrofit object
      Retrofit retrofit = new Retrofit.Builder().baseUrl( authority ).client( client ).addConverterFactory( JacksonConverterFactory.create() ).build();
    
      // Generate the token service
      TokenService tokenService = retrofit.create( TokenService.class );
    
      try
      {
         return tokenService.getAccessTokenFromAuthCode( tenantId, getAppId(), getAppPassword(), "authorization_code", authCode, getRedirectUrl() ).execute().body();
      }
      catch ( IOException e )
      {
         TokenResponse error = new TokenResponse();
         error.setError( "IOException" );
         error.setErrorDescription( e.getMessage() );
         return error;
      }
    

    I am getting following exception :

     org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoSuchMethodError: okio.BufferedSource.rangeEquals(JLokio/ByteString;)Z
    

    Below is my partial pom.xml :

        <!-- JACKSON DEPENDENCY FOR JSON PARSING -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>2.9.3</version>
        </dependency>
    
        <dependency>
          <groupId>com.fasterxml.jackson.core</groupId>
          <artifactId>jackson-annotations</artifactId>
          <version>2.9.3</version>
        </dependency>
    
        <dependency>
          <groupId>com.fasterxml.jackson.core</groupId>
          <artifactId>jackson-databind</artifactId>
          <version>2.9.3</version>
        </dependency>
    
        <!-- RETROFIT DEPENDENCY FOR SENDING HTTP REQUESTS -->
        <dependency>
          <groupId>com.squareup.retrofit2</groupId>
          <artifactId>retrofit</artifactId>
          <version>2.3.0</version>
        </dependency>
    
        <dependency>
          <groupId>com.squareup.retrofit2</groupId>
          <artifactId>converter-jackson</artifactId>
          <version>2.3.0</version>
        </dependency>
    
        <dependency>
          <groupId>com.squareup.okhttp3</groupId>
          <artifactId>logging-interceptor</artifactId>
          <version>3.9.1</version>
        </dependency>
    

    Can some one help me figure out, what's wrong with this?