-1

I have the following code, very simple:

package com.enrosz;

import java.util.HashMap;

import com.plaid.client.ApiClient;

public class MyPlaid {
    
public static void main(String[] args)  {
        
        HashMap<String, String> apiKeys = new HashMap<String, String>();
        apiKeys.put("clientId", "REDACTED");
        apiKeys.put("secret", "REDACTED");
        apiKeys.put("plaidVersion", "2020-09-14");
        
        ApiClient plaidApiClient = new ApiClient(apiKeys);
        
    }

}

When executed, the very last line immediately fails with this error:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by retrofit2.Platform (file:/Users/enroiv/.m2/repository/com/squareup/retrofit2/retrofit/2.9.0/retrofit-2.9.0.jar) to constructor java.lang.invoke.MethodHandles$Lookup(java.lang.Class,int)
WARNING: Please consider reporting this to the maintainers of retrofit2.Platform
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Exception in thread "main" java.lang.NoSuchMethodError: 'byte[] kotlin.collections.ArraysKt.copyInto(byte[], byte[], int, int, int)'
    at okio.Segment.writeTo(Segment.kt:169)
    at okio.Segment.compact(Segment.kt:152)
    at okio.Buffer.write(Buffer.kt:1842)
    at okio.Buffer.read(Buffer.kt:1854)
    at okio.Buffer.writeAll(Buffer.kt:1642)
    at okio.Options$Companion.buildTrieRecursive(Options.kt:187)
    at okio.Options$Companion.buildTrieRecursive(Options.kt:174)
    at okio.Options$Companion.buildTrieRecursive$default(Options.kt:113)
    at okio.Options$Companion.of(Options.kt:72)
    at okhttp3.internal.Util.<clinit>(Util.kt:70)
    at okhttp3.HttpUrl$Builder.parse$okhttp(HttpUrl.kt:1239)
    at okhttp3.HttpUrl$Companion.get(HttpUrl.kt:1633)
    at okhttp3.HttpUrl.get(HttpUrl.kt)
    at retrofit2.Retrofit$Builder.baseUrl(Retrofit.java:506)
    at com.plaid.client.ApiClient.createDefaultAdapter(ApiClient.java:156)
    at com.plaid.client.ApiClient.<init>(ApiClient.java:45)
    at com.plaid.client.ApiClient.<init>(ApiClient.java:92)
    at com.enrosz.MyPlaid.main(MyPlaid.java:16)

This seems to be an issue with the underlying libraries used by Plaid, specifically okhttp. I have not been able to resolve this issue. Contacted Plaid support but no response yet.

This is odd since this exact same code had been working until recently. Not sure if a breaking change was somehow introduced.

These are my POM dependencies, by the way:

<dependency>
        <groupId>com.plaid</groupId>
        <artifactId>plaid-java</artifactId>
        <version>16.2.0</version>
    </dependency>
    <dependency>
        <groupId>org.jetbrains.kotlin</groupId>
        <artifactId>kotlin-stdlib</artifactId>
        <version>1.9.0</version>
    </dependency>
    <dependency>
        <groupId>com.squareup.okhttp3</groupId>
        <artifactId>okhttp</artifactId>
        <version>4.11.0</version>
    </dependency>
enrosz
  • 1
  • 2

2 Answers2

0

This is probably an issue with the Kotlin version you are using. You need to be using at least Kotlin 1.3. See related questions here https://github.com/slackapi/java-slack-sdk/issues/518 and here OkHttp: NoSuchMethodError copyInto in TlsUtil

Alex
  • 1,245
  • 1
  • 9
  • 10
  • Thanks. I have tried several combinations of okhttp, kotlin and plaid-java versions based on code samples, plaid quickstart and plaid support feedback. As of now, the issue remains. I did update the original Q with the latest versions from my pom.xml – enrosz Aug 16 '23 at 15:49
0

Turned out to be a dll hell of sorts... went through all the versions and found the sweet spot:

<properties>
    <plaid-java.version>16.2.0</plaid-java.version>
    <kotlin-stdlib.version>1.9.70</kotlin-stdlib.version>
    <okhttp.version>4.2.2</okhttp.version><!-- Plaid case #532266. Don't change this version -->
    <maven-compiler-plugin.version>3.11.0</maven-compiler-plugin.version>
</properties>

Seems the latest okhttp i can use is 4.2.2.

I still have no idea why the quickstart works with 4.9.1 with seemingly the same code. I'll check if i get the spare time...

enrosz
  • 1
  • 2