Hello, I am trying to add kotlinx rpc in my app, b...
# kotlinx-rpc
d
Hello, I am trying to add kotlinx rpc in my app, but it fails to compile, details in thread.
Copy code
java.lang.NoClassDefFoundError: org/jetbrains/kotlinx/serialization/compiler/fir/SerializationFirResolveExtension
	at kotlinx.rpc.codegen.FirRPCServiceGenerator.<init>(FirRPCServiceGenerator.kt:84)
	at kotlinx.rpc.codegen.FirRPCExtensionRegistrar.configurePlugin$lambda$0(FirRPCExtensionRegistrar.kt:17)
	at org.jetbrains.kotlin.fir.extensions.FirExtensionService.registerExtensions(FirExtensionService.kt:43)
	at org.jetbrains.kotlin.fir.extensions.FirExtensionRegistrarKt.registerExtensions(FirExtensionRegistrar.kt:285)
	at org.jetbrains.kotlin.fir.session.FirSessionConfigurator.configure(FirSessionConfigurator.kt:53)
	at org.jetbrains.kotlin.fir.session.FirAbstractSessionFactory.createModuleBasedSession(FirAbstractSessionFactory.kt:119)
	at org.jetbrains.kotlin.fir.session.FirJvmSessionFactory.createModuleBasedSession(FirJvmSessionFactory.kt:102)
	at org.jetbrains.kotlin.cli.common.FirSessionConstructionUtilsKt.prepareJvmSessions(FirSessionConstructionUtils.kt:87)
	at org.jetbrains.kotlin.cli.jvm.compiler.pipeline.JvmCompilerPipelineKt.compileModuleToAnalyzedFir(jvmCompilerPipeline.kt:292)
	at org.jetbrains.kotlin.cli.jvm.compiler.pipeline.JvmCompilerPipelineKt.compileModulesUsingFrontendIrAndLightTree(jvmCompilerPipeline.kt:115)
	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:155)
	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:50)
	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:104)
	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:48)
	at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:101)
	at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:453)
	at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:62)
	at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.doCompile(IncrementalCompilerRunner.kt:506)
	at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl(IncrementalCompilerRunner.kt:423)
	at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileNonIncrementally(IncrementalCompilerRunner.kt:301)
	at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:129)
	at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:676)
	at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:92)
	at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1661)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:360)
	at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
	at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:712)
	at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:587)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:828)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:705)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:704)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: java.lang.ClassNotFoundException: org.jetbrains.kotlinx.serialization.compiler.fir.SerializationFirResolveExtension
	at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:592)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
	... 41 more
This is the folder that contains the RPC code. https://github.com/dragossusi/ktcnc/tree/develop/backend/rpc
a
Hi! What kotlin version do you use and have you added serialization plugin?
d
2.0.10
plugins { kotlin("multiplatform") kotlin("plugin.serialization") id("io.ktor.plugin") id("org.jetbrains.kotlinx.rpc.plugin") } kotlin { jvm() sourceSets { commonMain.dependencies { api(Libs.Coroutines.core) api(Libs.Serialization.json) implementation(Libs.Rpc.core) implementation(Libs.Rpc.serializationJson) implementation(Libs.datetime) } } }
My project also contains a lot of modules, some depend on compose and dagger
I'm not sure if this might be an issue with KSP, which is used for dagger
a
I will take a look at the project and see what I can find
👍🏻 1
Hi @Dragos Rachieru! In your
backend:server
module you applied rpc plugin without serialization:
Copy code
plugins {
    kotlin("jvm")
    id("org.jetbrains.kotlinx.rpc.plugin")
    id("io.ktor.plugin")
}
As I don't see any service defenitions, I suspect you intended to apply
org.jetbrains.kotlinx.rpc.platform
instead to use bom versions, or it is there just by a accident. Adding serialization plugin or removing rpc plugin will solve your problem And I'll take a note for more user friendly experience in similar scenarios
d
I do not need bom, since I manually specify the library version. What I use in that module is an implementation of an RPC
do I still need to apply the rpc plugin?
a
Yes, and it does not require an rpc plugin, only service declaration does:
interface FileSystemService : RPC
d
I want to keep all the
Serializable
classes and
RPC
interfaces in
backend:rpc
and i'm keeping all the implementations for these `RPC`s in
backend:server
quite strange that
./gradlew build :backend:rpc
failed
a
It failed with the same message?
d
something similar, related to
IR
a
Hm, I only get
Copy code
Execution failed for task ':backend:rpc:shadowJar'.
> Error while evaluating property 'mainClassName' of task ':backend:rpc:shadowJar'.
   > Cannot query the value of extension 'application' property 'mainClass' because it has no value available.
trying to run
./gradlew :backend:rpc:build
👍🏻 1
I'm on the
develop
branch currently
d
I am not currently at my PC so I cannot test this right now, I remember running the
build
task using Intellij, not
gradlew
I can try again tonight, I have also upgraded to krpc
0.3.0
using Github directly to see if the same error is shown in Github actions
a
no problem, please let me know if something still not working when you'll be able to run it
btw,
0.3.0
contains breaking changes in package names, so Ci will probably fail with compilation errors
d
I tried it yesterday with serialization added to
backend:server
and the build command succeeded
thanks a lot!
👍 1