0

Currently, I am upgrading my Square Java SDK from version 2 to 20.1.0.20220616, but when I try to get SquareClient then it throws below error:

org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoSuchMethodError: okhttp3.OkHttpClient$Builder.callTimeout(JLjava/util/concurrent/TimeUnit;)Lokhttp3/OkHttpClient$Builder

My code in Java is written like below. Here, apikey is access_token of merchant which I stored in db. Also, I tried for SANDBOX environment. Can someone please help me to solve this.
also need to find compatible versions for square SDK 20.1.0.20220616 with appropriate okhttp library which can work with above square SDK

Environment environment = Environment.PRODUCTION;
return new SquareClient.Builder().environment(environment)
                .accessToken(apiKey).build();
Umesh Goti
  • 39
  • 5
  • You have an incompatible combination of libraries. The error suggests that the Square client requires a different version of OkHttp than you have currently on the classpath. Find out which version the Square client requires, find out why you have a different version, and then try upgrading or downgrading OkHttp (or Square). – Mark Rotteveel Jun 29 '22 at 07:11
  • as mentioned here in compile dependencies section https://mvnrepository.com/artifact/com.squareup/square/20.1.0.20220616 i have used okhttp version 4.10.0 then also it says NoclassDefFound can you please help me which okhttp is compatible with square 20.1.0.20220616? or how can i find compatible versions – Umesh Goti Jun 29 '22 at 09:01
  • Check the actual dependencies on your classpath. Likely something else is pulling in a different version (e.g. use `mvn dependency:tree` to check) – Mark Rotteveel Jun 29 '22 at 09:20
  • thanks for helping me. as i am trying with different version of okhttp(4.10.0, 5.0.0-alpha.10, 5.0.0-alpha.4) with square version 20.1.0.20220616 but this is not succeed. also checked above versions with command `mvn dependency:tree`. if you have an idea which version is compatible can you please let me know – Umesh Goti Jun 29 '22 at 09:48
  • What happens if you use OkHttp3 4.9.1 which is actually listed for that version of Square? – Mark Rotteveel Jun 29 '22 at 09:49
  • That said, the error itself seems to suggest you have OkHttp3 version 3.x on your classpath. Alternatively, see https://github.com/square/square-java-sdk/issues/40 – Mark Rotteveel Jun 29 '22 at 09:52
  • with OkHttp3 4.9.1 it throws error like 'java.lang.NoSuchMethodError: kotlin.collections.ArraysKt.copyInto([B[BIII)[B' – Umesh Goti Jun 29 '22 at 10:06
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/246017/discussion-between-umesh-goti-and-mark-rotteveel). – Umesh Goti Jun 29 '22 at 10:24

0 Answers0