Open VadymIgnatiev opened 11 months ago
I believe the error is due to different versions of kotlin.time.Duration
being loaded by your plugin and IntelliJ's class loaders. Aligning the Kotlin version and dependencies with IntelliJ IDEA's should resolve this conflict.
Same issue here:
2024-07-14 14:25:01,224 [ 18750] SEVERE - #o.j.c.AsyncPromise - loader constraint violation: when resolving method 'long kotlin.time.Duration.toLong-impl(long, kotlin.time.DurationUnit)' the class loader com.intellij.ide.plugins.cl.PluginClassLoader @2579be1 of the current class, com/aallam/openai/client/internal/HttpClientKt$createHttpClient$configuration$1$5, and the class loader com.intellij.util.lang.PathClassLoader @d7b1517 for the method's defining class, kotlin/time/Duration, have different Class objects for the type kotlin/time/DurationUnit used in the signature (com.aallam.openai.client.internal.HttpClientKt$createHttpClient$configuration$1$5 is in unnamed module of loader com.intellij.ide.plugins.cl.PluginClassLoader @2579be1, parent loader 'bootstrap'; kotlin.time.Duration is in unnamed module of loader com.intellij.util.lang.PathClassLoader @d7b1517)
java.lang.LinkageError: loader constraint violation: when resolving method 'long kotlin.time.Duration.toLong-impl(long, kotlin.time.DurationUnit)' the class loader com.intellij.ide.plugins.cl.PluginClassLoader @2579be1 of the current class, com/aallam/openai/client/internal/HttpClientKt$createHttpClient$configuration$1$5, and the class loader com.intellij.util.lang.PathClassLoader @d7b1517 for the method's defining class, kotlin/time/Duration, have different Class objects for the type kotlin/time/DurationUnit used in the signature (com.aallam.openai.client.internal.HttpClientKt$createHttpClient$configuration$1$5 is in unnamed module of loader com.intellij.ide.plugins.cl.PluginClassLoader @2579be1, parent loader 'bootstrap'; kotlin.time.Duration is in unnamed module of loader com.intellij.util.lang.PathClassLoader @d7b1517)
at com.aallam.openai.client.internal.HttpClientKt$createHttpClient$configuration$1$5.invoke(HttpClient.kt:57)
at com.aallam.openai.client.internal.HttpClientKt$createHttpClient$configuration$1$5.invoke(HttpClient.kt:55)
at io.ktor.client.HttpClientConfig$install$2.invoke(HttpClientConfig.kt:76)
at io.ktor.client.HttpClientConfig$install$2.invoke(HttpClientConfig.kt:72)
at io.ktor.client.plugins.HttpTimeout$Plugin.prepare(HttpTimeout.kt:140)
at io.ktor.client.plugins.HttpTimeout$Plugin.prepare(HttpTimeout.kt:128)
at io.ktor.client.HttpClientConfig$install$3.invoke(HttpClientConfig.kt:84)
at io.ktor.client.HttpClientConfig$install$3.invoke(HttpClientConfig.kt:81)
at io.ktor.client.HttpClientConfig.install(HttpClientConfig.kt:104)
at io.ktor.client.HttpClient.<init>(HttpClient.kt:172)
at io.ktor.client.HttpClient.<init>(HttpClient.kt:84)
at io.ktor.client.HttpClientKt.HttpClient(HttpClient.kt:63)
at com.aallam.openai.client.internal.HttpClientKt.createHttpClient(HttpClient.kt:87)
at com.aallam.openai.client.OpenAIKt.OpenAI(OpenAI.kt:60)
build.gradle.kts dependecies section:
dependencies {
val ktor_version = "2.3.12"
//implementation("org.slf4j:slf4j-api:2.0.7")
implementation("com.aallam.openai:openai-client:3.8.1") {
exclude(group = "org.slf4j", module = "slf4j-api")
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib")
}
implementation("io.ktor:ktor-client-java-jvm:$ktor_version") {
exclude(group = "org.slf4j", module = "slf4j-api")
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib")
}
}
I'm new to Kotlin development and using gradle, so my problems may seem stupid. I want to connect your library to develop a plugin for Jet Brains IDEs, for my custom tasks, but I get the following(in the bottom) error when running your code.
try to add (openai-client:3.6.2) use for development IntelliJ IDEA 2023.3 (Ultimate Edition) Kotlin version kotlin = "1.9.0", the same as in gradle/libs.versions.toml Run on windows IntelliJ IDEA 2022.3.3 (Community Edition)
added your library through gradle my dependency in build.gradle.kts
settings.gradle.kts
java.lang.LinkageError: loader constraint violation: when resolving method 'long kotlin.time.Duration.toLong-impl(long, kotlin.time.DurationUnit)' the class loader com.intellij.ide.plugins.cl.PluginClassLoader @7193fbf1 of the current class, com/aallam/openai/client/internal/HttpClientKt$createHttpClient$configuration$1$5, and the class loader com.intellij.util.lang.PathClassLoader @7e0babb1 for the method's defining class, kotlin/time/Duration, have different Class objects for the type kotlin/time/DurationUnit used in the signature (com.aallam.openai.client.internal.HttpClientKt$createHttpClient$configuration$1$5 is in unnamed module of loader com.intellij.ide.plugins.cl.PluginClassLoader @7193fbf1, parent loader 'bootstrap'; kotlin.time.Duration is in unnamed module of loader com.intellij.util.lang.PathClassLoader @7e0babb1) at com.aallam.openai.client.internal.HttpClientKt$createHttpClient$configuration$1$5.invoke(HttpClient.kt:57) at com.aallam.openai.client.internal.HttpClientKt$createHttpClient$configuration$1$5.invoke(HttpClient.kt:55) at io.ktor.client.HttpClientConfig$install$2.invoke(HttpClientConfig.kt:76) at io.ktor.client.HttpClientConfig$install$2.invoke(HttpClientConfig.kt:72) at io.ktor.client.plugins.HttpTimeout$Plugin.prepare(HttpTimeout.kt:140) at io.ktor.client.plugins.HttpTimeout$Plugin.prepare(HttpTimeout.kt:128) at io.ktor.client.HttpClientConfig$install$3.invoke(HttpClientConfig.kt:84) at io.ktor.client.HttpClientConfig$install$3.invoke(HttpClientConfig.kt:81) at io.ktor.client.HttpClientConfig.install(HttpClientConfig.kt:104) at io.ktor.client.HttpClient.<init>(HttpClient.kt:172) at io.ktor.client.HttpClient.<init>(HttpClient.kt:84) at io.ktor.client.HttpClientKt.HttpClient(HttpClient.kt:43) at io.ktor.client.HttpClientJvmKt.HttpClient(HttpClientJvm.kt:21) at com.aallam.openai.client.internal.HttpClientKt.createHttpClient(HttpClient.kt:89) at com.aallam.openai.client.OpenAIKt.OpenAI(OpenAI.kt:60) at com.aallam.openai.client.OpenAIKt.OpenAI(OpenAI.kt:40) at com.aallam.openai.client.OpenAIKt.OpenAI$default(OpenAI.kt:30) at com.github.vadymignatiev.octopusrider.ChatPresenter.<init>(ChatPresenter.kt:15) at com.github.vadymignatiev.octopusrider.ChatAction.actionPerformed(ChatAction.kt:9) at com.intellij.openapi.actionSystem.ex.ActionUtil.doPerformActionOrShowPopup(ActionUtil.java:327) at com.intellij.ide.actions.GotoActionAction.lambda$performActionImpl$4(GotoActionAction.java:91) at com.intellij.openapi.actionSystem.ex.ActionUtil.performDumbAwareWithCallbacks(ActionUtil.java:350) at com.intellij.ide.actions.GotoActionAction.performActionImpl(GotoActionAction.java:90) at com.intellij.ide.actions.GotoActionAction.lambda$performAction$2(GotoActionAction.java:70) at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:209) at com.intellij.openapi.application.TransactionGuardImpl.access$100(TransactionGuardImpl.java:21) at com.intellij.openapi.application.TransactionGuardImpl$1.run(TransactionGuardImpl.java:191) at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:838) at com.intellij.openapi.application.impl.ApplicationImpl$3.run(ApplicationImpl.java:454) at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:74) at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:114) at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:36) at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318) at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:779) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:730) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:724) at java.base/java.security.AccessController.doPrivileged(AccessController.java:399) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86) at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:749) at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:909) at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:756) at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$5(IdeEventQueue.java:437) at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:787) at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$6(IdeEventQueue.java:436) at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:105) at com.intellij.ide.IdeEventQueue.performActivity(IdeEventQueue.java:615) at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:434) at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:838) at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:480) at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207) at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128) at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105) at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)