kmongo icon indicating copy to clipboard operation
kmongo copied to clipboard

IllegalAccessError: tried to access method org.bson.internal.OverridableUuidRepresentationCodecRegistry

Open Nopock opened this issue 2 years ago • 4 comments

Whenever I run my application I get this error:

java.lang.IllegalAccessError: tried to access method org.bson.internal.OverridableUuidRepresentationCodecRegistry.(Lorg/bson/codecs/configuration/CodecProvider;Lorg/bson/UuidRepresentation;)V from class org.litote.kmongo.KMongo at org.litote.kmongo.KMongo.createRegistry(KMongo.kt:87) ~[?:?] at org.litote.kmongo.KMongo.createClient(KMongo.kt:78) ~[?:?] at org.hyrical.influx.storage.Storage.load(Storage.kt:30) ~[?:?]

dependencies {
    implementation 'org.litote.kmongo:kmongo-serialization:4.6.1'
    implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.3"
    implementation 'org.mongodb:bson:4.7.1'
}

and I run shadowJar

Here is my implementation (It errors when I call this)

    lateinit var client: MongoClientSettings

    lateinit var mongoClient: MongoClient
    lateinit var database: MongoDatabase

    fun load() {
        client = MongoClientSettings.builder()
            .applyConnectionString(ConnectionString("my mongoDb URL"))
            .uuidRepresentation(UuidRepresentation.STANDARD)
            .build()

        mongoClient = KMongo.createClient(client)

        database = mongoClient.getDatabase("Influx")
    }

Specifically on the line where I initialize mongoClient.

Nopock avatar Aug 08 '22 21:08 Nopock

This is caused by the protocol in the ihcf event causing an abstract class to throw an java exception handler

ohemilyy avatar Aug 08 '22 21:08 ohemilyy

First idea: try to use org.litote.kmongo:kmongo-serialization:4.7.0.

Because org.litote.kmongo:kmongo-serialization:4.6.1 is compiled with org.mongodb:bson:4.6.0 (and not 4.7.1)

HTH

zigzago avatar Aug 09 '22 18:08 zigzago

First idea: try to use org.litote.kmongo:kmongo-serialization:4.7.0.

Because org.litote.kmongo:kmongo-serialization:4.6.1 is compiled with org.mongodb:bson:4.6.0 (and not 4.7.1)

HTH

Sorry for the late reply.

Still seems to throw the exact same error!

Nopock avatar Aug 13 '22 07:08 Nopock

Check if you have other version of mongo jar in your dependencies (from third party dependencies). Usually this is the origin of this stacktrace

HTH

zigzago avatar Aug 13 '22 20:08 zigzago