Kotlinx.serialization: SerializationComponentRegistrar is not compatible with this version of compiler (1.2.31?)

Created on 16 Feb 2018  Â·  28Comments  Â·  Source: Kotlin/kotlinx.serialization

Error:Kotlin: [Internal Error] java.lang.IllegalStateException: The provided plugin org.jetbrains.kotlinx.serialization.compiler.extensions.SerializationComponentRegistrar is not compatible with this version of compiler
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.(KotlinCoreEnvironment.kt:178)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.(KotlinCoreEnvironment.kt:114)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.createForProduction(KotlinCoreEnvironment.kt:409)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.createCoreEnvironment(K2JVMCompiler.kt:286)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.createEnvironmentWithScriptingSupport(K2JVMCompiler.kt:276)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:155)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:63)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.java:109)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.java:53)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:92)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$$inlined$ifAlive$lambda$1.invoke(CompileServiceImpl.kt:381)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$$inlined$ifAlive$lambda$1.invoke(CompileServiceImpl.kt:97)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$$inlined$ifAlive$lambda$2.invoke(CompileServiceImpl.kt:895)
at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$$inlined$ifAlive$lambda$2.invoke(CompileServiceImpl.kt:97)
at org.jetbrains.kotlin.daemon.common.DummyProfiler.withMeasure(PerfUtils.kt:137)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.checkedCompile(CompileServiceImpl.kt:925)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.doCompile(CompileServiceImpl.kt:894)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:379)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:346)
at sun.rmi.transport.Transport$1.run(Transport.java:200)
at sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.AbstractMethodError: org.jetbrains.kotlinx.serialization.compiler.extensions.SerializationComponentRegistrar.registerProjectComponents(Lcom/intellij/mock/MockProject;Lorg/jetbrains/kotlin/config/CompilerConfiguration;)V
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.(KotlinCoreEnvironment.kt:176)
... 34 more

Most helpful comment

I also see this issue using IDEA builds (but not when using Gradle command line builds). I've had this issue off and on over several versions.

I briefly had things working under the 1.2.21 version of the Idea Kotlin plugin. The upgrade to the 1.2.30 IDEA plugin broke the build, and so far I am unable to repair it (I've tried removing the plugin, and installing 1.2.1 from disk. No luck there).

It seems that every patch release breaks this build, which makes the serialization library practically unusable with IDEA projects. Since everything works nicely for CLI builds, it could be an issue specific to the IDEA plugin, not this library, but if this library depends on a specific patch version of the Kotlin compiler, that seems like a serious flaw.

All 28 comments

Which version of Kotlin compiler do you use?

@sandwwraith 1.2.21

Does this error occur during Gradle build or IDEA build?

I don’t know why and how. But it works now. Thank you

I do have the same issue. It only happens when I build using the IDEA build from the IDE

I also see this issue using IDEA builds (but not when using Gradle command line builds). I've had this issue off and on over several versions.

I briefly had things working under the 1.2.21 version of the Idea Kotlin plugin. The upgrade to the 1.2.30 IDEA plugin broke the build, and so far I am unable to repair it (I've tried removing the plugin, and installing 1.2.1 from disk. No luck there).

It seems that every patch release breaks this build, which makes the serialization library practically unusable with IDEA projects. Since everything works nicely for CLI builds, it could be an issue specific to the IDEA plugin, not this library, but if this library depends on a specific patch version of the Kotlin compiler, that seems like a serious flaw.

This library does not depend on any particular patch version of compiler; however, because it uses internal and undocumented compiler API, which may vary from version to version, sometimes it got broken.

However, this issue is most commonly caused by incorrect project import from gradle. Re-importing the project forces idea to resolve plugin jars correctly.

I am still getting this. Tried "Synchronize", "invalidate Caches / Restart" and finally a full re-import of the project but nothing made any difference on IntelliJ IDEA 2018.1, Kotlin compiler version 1.2.31, kotlinx.serialization version 0.4.2 (all the latest as of this writing).

Can this bug be re-opened?

@gladed Do you have stacktrace same as here or same as #97 ?

It's the exception in this issue. I could only avoid it by using "Delegate IDE Build/Run Actions to Gradle".

Delegate IDE Build/Run Actions to Gradle didn't fix it for me. Still got this error:

Error:Kotlin: [Internal Error] java.lang.IllegalStateException: The provided plugin org.jetbrains.kotlinx.serialization.compiler.extensions.SerializationComponentRegistrar is not compatible with this version of compiler
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.<init>(KotlinCoreEnvironment.kt:181)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.<init>(KotlinCoreEnvironment.kt:117)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.createForProduction(KotlinCoreEnvironment.kt:413)
    at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.createCoreEnvironment(K2JVMCompiler.kt:276)
    at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:154)
    at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:63)
    at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.java:108)
    at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.java:52)
    at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:92)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$$inlined$ifAlive$lambda$1.invoke(CompileServiceImpl.kt:389)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$$inlined$ifAlive$lambda$1.invoke(CompileServiceImpl.kt:97)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$$inlined$ifAlive$lambda$2.invoke(CompileServiceImpl.kt:909)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$$inlined$ifAlive$lambda$2.invoke(CompileServiceImpl.kt:97)
    at org.jetbrains.kotlin.daemon.common.DummyProfiler.withMeasure(PerfUtils.kt:137)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl.checkedCompile(CompileServiceImpl.kt:939)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl.doCompile(CompileServiceImpl.kt:908)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:387)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:361)
    at sun.rmi.transport.Transport$1.run(Transport.java:200)
    at sun.rmi.transport.Transport$1.run(Transport.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.AbstractMethodError
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.<init>(KotlinCoreEnvironment.kt:179)
    ... 33 more

It would be really good if the code on this github repo, worked out the box.

ran into this issue while evaluating kotlin as a groovy replacement - guess it's not ready for prime time.
used the same versions numbers given in the example in this project:

  ext.kotlin_version = '1.2.30'
  ext.serialization_version = '0.4.2'

Intellij does have a warning in the build file:

Kotlin version that is used for building with Gradle (1.2.30) differs from the one bundled into the IDE plugin (1.2.31)

changing the version number to 1.2.31 does not help.
Have to admit I'm puzzled, shouldn't the kotlin version number override the version in the IDE??

I am having the same problem. Delegating build to gradle works here...

thanks, I tried that, and was able to run the file, but ran into another execption:

Exception in thread "main" kotlinx.serialization.SerializationException: Can't locate default serializer for class class K2Kt$main$x$1 (Kotlin reflection is not available)
in my case I was using an anonymous object:

fun main(args: Array<String>) {
    val x = object {
        val a = 12
    }
    println(JSON.stringify(x))
}

Pretty disappointing, as I said above, clearly not ready for prime time.

There's a recently published version of IDEA plugin compatible with 1.2.31 Kotlin IDEA plugin, please try it out and say if it works: link. I've updated the README accordingly. However, delegating build to gradle is still preferred method to work, since JPS has no multiplatform support.

@davidmoshal No, kotlin version number in buildscript doesn't override version in IDE.

@davidm-public Have you read the docs? You need to mark your class as @Serializable to be able to work with its generated serializers, since this library does not use reflection

@sandwwraith which docs?

I tried adding `@Serializable' to the anon object in my example above but that didn't work.

Don't get me wrong, I like the concept of Kotlin, and have followed it since the beginning, 2012 I think, just saying that it doesn't seem stable enough to replace Groovy

  • not that Groovy really needs replacing.

@davidm-public This works good for me:

import kotlinx.serialization.Serializable
import kotlinx.serialization.json.JSON

fun main(args: Array<String>) {
    val x = @Serializable object {
        val a = 12
    }
    println(JSON.stringify(x)) // prints {"a":12}
}

So it's likely you forgot to apply plugin or delegate build, etc.. If you still feel that there's something wrong – feel free to open separate issue where you can describe your setup and example code in details, since it's completely offtopic here.

And let me remind you that this library is still in incubating phase and its problems does not relate with Kotlin itself, which has been released a while ago. You can always search mature solutions in Java reflection world, since Kotlin has 100% interopability with it.

thanks, that's what I tried, will try again later.
it does work with other, non-anonymous, classes.

seems to compile faster than Groovy.

Dave

I noticed I could no longer run tests from the IntelliJ IDE (only through Gradle). While investigating this I ran into this build error, which I did not notice at first since I typically use Gradle to build.

Updating to the the latest IntelliJ kotlinx.serialization plugin as instructed by the documentation worked for me. (I had the previous version installed.)

Installing the plugin has never been enough for me, there's something else at play here too. Strangely, if I have the plugin installed, and then IntelliJ updates, it starts working(!).

I am seeing this with 1.2.50

same problem with 1.2.51

  1. Check version of Kotlin plugin in IDEA and build.gradle, check version of serialization plugin in IDEA and build.gradle, then check compatibility table.
  2. Re-import project from gradle.

~I have the same issue, but when I run the project on the command line it works perfectly.
It looks like an IDEA bug.~

After I made the steps suggested by @sandwwraith it worked.

I think this is kinda old, and since Kotlin serialization IDE plugin is bundled into Kotlin IDE plugin since Kotlin 1.3, this is also obsolete.

Was this page helpful?
0 / 5 - 0 ratings