#kotlin #gradle #protocol-buffers #grpc #micronaut
#котлин #gradle #буферы протокола #grpc #micronaut
Вопрос:
Ближайшая проблема, которую я нашел, — это эта, и в основном она гласит: «… вы используете версию kotlin-stdlib в пути к классу среды выполнения не ниже, чем в пути к классу компиляции … »
Насколько я вижу, я прав с версиями kotlin.
Весь мой проект довольно маленький и его можно загрузить с github
build.gradle
plugins {
id("org.jetbrains.kotlin.jvm") version "1.4.10"
id("org.jetbrains.kotlin.kapt") version "1.4.10"
id("org.jetbrains.kotlin.plugin.allopen") version "1.4.10"
id("com.github.johnrengelman.shadow") version "6.1.0"
id("io.micronaut.application") version "1.2.0"
id("com.google.protobuf") version "0.8.13"
}
version = "0.1"
group = "com.tolearn"
repositories {
mavenCentral()
jcenter()
}
micronaut {
testRuntime("junit5")
processing {
incremental(true)
annotations("com.tolearn.*")
}
}
dependencies {
implementation("io.grpc:protoc-gen-grpc-kotlin:1.0.0:jdk7@jar")
api("io.grpc:grpc-kotlin-stub:1.0.0")
implementation("io.micronaut:micronaut-validation")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlinVersion}")
implementation("org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}")
implementation("io.micronaut.kotlin:micronaut-kotlin-runtime")
implementation("io.micronaut:micronaut-runtime")
implementation("io.micronaut.grpc:micronaut-grpc-runtime")
implementation("javax.annotation:javax.annotation-api")
implementation("io.micronaut:micronaut-http-client")
runtimeOnly("ch.qos.logback:logback-classic")
runtimeOnly("com.fasterxml.jackson.module:jackson-module-kotlin")
}
application {
mainClass.set("com.tolearn.ApplicationKt")
}
java {
sourceCompatibility = JavaVersion.toVersion("11")
}
tasks {
compileKotlin {
kotlinOptions {
jvmTarget = "11"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "11"
}
}
}
sourceSets {
main {
java {
srcDirs("build/generated/source/proto/main/grpc")
srcDirs("build/generated/source/proto/main/java")
srcDirs 'build/generated/source/proto/main/grpckt'
}
}
}
protobuf {
protoc { artifact = "com.google.protobuf:protoc:3.14.0" }
plugins {
grpc { artifact = "io.grpc:protoc-gen-grpc-java:1.34.1" }
grpckt { artifact = "io.grpc:protoc-gen-grpc-kotlin:1.0.0:jdk7@jar" }
}
generateProtoTasks {
all()*.plugins {
grpc {}
grpckt {}
}
}
}
gradle.properties
micronautVersion=2.2.2
kotlinVersion=1.4.10
Полные журналы, когда я пытаюсь отладить приложение внутри IntelliJ
C:JDKsjdk-11.0.6binjava.exe "-javaagent:C:Program FilesJetBrainsIntelliJ IDEA Community Edition 2020.1libidea_rt.jar=57835:C:Program FilesJetBrainsIntelliJ IDEA Community Edition 2020.1bin" -Dfile.encoding=UTF-8 -classpath C:_dtoLearndemo-moneybuildclassesjavamain;C:_dtoLearndemo-moneybuildclasseskotlinmain;C:_dtoLearndemo-moneybuildtmpkapt3classesmain;C:_dtoLearndemo-moneybuildresourcesmain;C:UsersCast.gradlecachesmodules-2files-2.1io.grpcgrpc-kotlin-stub1.0.0a9b64135291f02726f437bf82822142dea3d963dgrpc-kotlin-stub-1.0.0.jar;C:UsersCast.gradlecachesmodules-2files-2.1io.grpcprotoc-gen-grpc-kotlin1.0.0d6c8cbe29c60b202165593be5244ce43d37378acprotoc-gen-grpc-kotlin-1.0.0-jdk7.jar;C:UsersCast.gradlecachesmodules-2files-2.1io.micronautmicronaut-validation2.2.24c9978ae69745ab3c5afd37d3c2e6c7f5a59190bmicronaut-validation-2.2.2.jar;C:UsersCast.gradlecachesmodules-2files-2.1org.jetbrains.kotlinkotlin-stdlib-jdk81.4.10998caa30623f73223194a8b657abd2baec4880eakotlin-stdlib-jdk8-1.4.10.jar;C:UsersCast.gradlecachesmodules-2files-2.1org.jetbrains.kotlinkotlin-reflect1.4.10e2b3c6695eee6085e606d96d685396dce23a3a06kotlin-reflect-1.4.10.jar;C:UsersCast.gradlecachesmodules-2files-2.1io.micronaut.kotlinmicronaut-kotlin-runtime2.2.0b8b24a7e5ea4d68afd6edc283f2b1f944bbf2cc7micronaut-kotlin-runtime-2.2.0.jar;C:UsersCast.gradlecachesmodules-2files-2.1io.micronautmicronaut-http-client2.2.2740a9b3ee54d66b838675e62df3c9bbdd8f1028bmicronaut-http-client-2.2.2.jar;C:UsersCast.gradlecachesmodules-2files-2.1io.micronaut.grpcmicronaut-grpc-runtime2.2.01ed2e5c0f592d2f92eab105f60293f0c1cab6e92micronaut-grpc-runtime-2.2.0.jar;C:UsersCast.gradlecachesmodules-2files-2.1io.micronautmicronaut-runtime2.2.2ffee1b2088cd3bd699646940dc37ccc537d6f77micronaut-runtime-2.2.2.jar;C:UsersCast.gradlecachesmodules-2files-2.1io.micronautmicronaut-inject2.2.2dbbd8cf931e3714ef0e9ce635a1023a383785c25micronaut-inject-2.2.2.jar;C:UsersCast.gradlecachesmodules-2files-2.1javax.annotationjavax.annotation-api1.3.2934c04d3cfef185a8008e7bf34331b79730a9d43javax.annotation-api-1.3.2.jar;C:UsersCast.gradlecachesmodules-2files-2.1io.grpcgrpc-protobuf1.33.14999a8c87e4264be11749b0e3c82526fb7481dafgrpc-protobuf-1.33.1.jar;C:UsersCast.gradlecachesmodules-2files-2.1io.grpcgrpc-stub1.33.1cf2c3b997646a3f065efbaa72528dc7c67e80d77grpc-stub-1.33.1.jar;C:UsersCast.gradlecachesmodules-2files-2.1io.micronautmicronaut-http2.2.23e8dbd9635f2ae40acf95dfeecf424cc46d759a0micronaut-http-2.2.2.jar;C:UsersCast.gradlecachesmodules-2files-2.1org.slf4jslf4j-api1.7.2677100a62c2e6f04b53977b9f541044d7d722693dslf4j-api-1.7.26.jar;C:UsersCast.gradlecachesmodules-2files-2.1javax.validationvalidation-api2.0.1.Finalcb855558e6271b1b32e716d24cb85c7f583ce09evalidation-api-2.0.1.Final.jar;C:UsersCast.gradlecachesmodules-2files-2.1org.jetbrains.kotlinkotlin-stdlib-jdk71.4.1030e46450b0bb3dbf43898d2f461be4a942784780kotlin-stdlib-jdk7-1.4.10.jar;C:UsersCast.gradlecachesmodules-2files-2.1org.jetbrains.kotlinkotlin-stdlib1.4.10ea29e063d2bbe695be13e9d044dcfb0c7add398ekotlin-stdlib-1.4.10.jar;C:UsersCast.gradlecachesmodules-2files-2.1io.micronautmicronaut-http-client-core2.2.2b939e521a859d2f691f352d2d274693d2e979039micronaut-http-client-core-2.2.2.jar;C:UsersCast.gradlecachesmodules-2files-2.1io.micronautmicronaut-http-netty2.2.2d95de1cfb8f14ebe7c025ed1d994734bdc97aa76micronaut-http-netty-2.2.2.jar;C:UsersCast.gradlecachesmodules-2files-2.1io.micronautmicronaut-websocket2.2.26b9727c73e352f3c2b8ad86f74f172de465c5035micronaut-websocket-2.2.2.jar;C:UsersCast.gradlecachesmodules-2files-2.1io.nettynetty-handler-proxy4.1.56.Final3acd2ead521786303faf2f85308b98ba174c53b6netty-handler-proxy-4.1.56.Final.jar;C:UsersCast.gradlecachesmodules-2files-2.1io.micronaut.grpcmicronaut-grpc-client-runtime2.2.089ebc47606ca77e186a3e182ac5eccd0cfce193emicronaut-grpc-client-runtime-2.2.0.jar;C:UsersCast.gradlecachesmodules-2files-2.1io.micronaut.grpcmicronaut-grpc-server-runtime2.2.0f4e9472b6124f5e7db1ce229c7a1059db6589b84micronaut-grpc-server-runtime-2.2.0.jar;C:UsersCast.gradlecachesmodules-2files-2.1io.micronautmicronaut-aop2.2.21389d1a032d2d6599c132e3f1daab239724e691dmicronaut-aop-2.2.2.jar;C:UsersCast.gradlecachesmodules-2files-2.1io.reactivex.rxjava2rxjava2.2.1018e9edc67e0abaa03713eeb9ca2cb0e30c859de4rxjava-2.2.10.jar;C:UsersCast.gradlecachesmodules-2files-2.1com.fasterxml.jackson.datatypejackson-datatype-jdk82.11.2d4c1933a8d62db65c3d5a5cd809511e021a189c0jackson-datatype-jdk8-2.11.2.jar;C:UsersCast.gradlecachesmodules-2files-2.1com.fasterxml.jackson.datatypejackson-datatype-jsr3102.11.2e6235e5eb3cf3edd2a95cd0dc96bc48aeb309e8ajackson-datatype-jsr310-2.11.2.jar;C:UsersCast.gradlecachesmodules-2files-2.1io.micronautmicronaut-core2.2.2c85844828723dcd0ccbf9fa70cb406d6c49d083bmicronaut-core-2.2.2.jar;C:UsersCast.gradlecachesmodules-2files-2.1org.yamlsnakeyaml1.26a78a8747147d2c5807683e76ec2b633e95c14fe9snakeyaml-1.26.jar;C:UsersCast.gradlecachesmodules-2files-2.1javax.injectjavax.inject16975da39a7040257bd51d21a231b76c915872d38javax.inject-1.jar;C:UsersCast.gradlecachesmodules-2files-2.1io.grpcgrpc-protobuf-lite1.33.11972b32eca6661ac99f0d0d1f6bc78836a0aaa98grpc-protobuf-lite-1.33.1.jar;C:UsersCast.gradlecachesmodules-2files-2.1io.grpcgrpc-api1.33.1110c50b7376a5083392a35cace95fbe121fefbc3grpc-api-1.33.1.jar;C:UsersCast.gradlecachesmodules-2files-2.1com.google.code.findbugsjsr3053.0.225ea2e8b0c338a877313bd4672d3fe056ea78f0djsr305-3.0.2.jar;C:UsersCast.gradlecachesmodules-2files-2.1com.google.protobufprotobuf-java3.14.0bb6430f70647fc349fffd1690ddb889dc3ea6699protobuf-java-3.14.0.jar;C:UsersCast.gradlecachesmodules-2files-2.1com.google.api.grpcproto-google-common-protos1.17.040471bf2045151c17da555889b5550fcfd5224a8proto-google-common-protos-1.17.0.jar;C:UsersCast.gradlecachesmodules-2files-2.1com.google.guavaguava29.0-androida51b7d9cbfcce79a88c961907c1767c6de201f31guava-29.0-android.jar;C:UsersCast.gradlecachesmodules-2files-2.1com.google.errorproneerror_prone_annotations2.3.4dac170e4594de319655ffb62f41cbd6dbb5e601eerror_prone_annotations-2.3.4.jar;C:UsersCast.gradlecachesmodules-2files-2.1org.jetbrains.kotlinkotlin-stdlib-common1.4.106229be3465805c99db1142ad75e6c6ddeac0b04ckotlin-stdlib-common-1.4.10.jar;C:UsersCast.gradlecachesmodules-2files-2.1org.jetbrainsannotations13.0919f0dfe192fb4e063e7dacadee7f8bb9a2672a9annotations-13.0.jar;C:UsersCast.gradlecachesmodules-2files-2.1io.micronautmicronaut-buffer-netty2.2.2fec1f3c421efbffaefa261e85d0f967b5157cd52micronaut-buffer-netty-2.2.2.jar;C:UsersCast.gradlecachesmodules-2files-2.1io.nettynetty-codec-http24.1.56.Final124a9dc7d71e1d8df8cddf588f52f3a353ed30c6netty-codec-http2-4.1.56.Final.jar;C:UsersCast.gradlecachesmodules-2files-2.1io.nettynetty-codec-http4.1.56.Finalb67fa83d89476f66de30fa0808cf2fd019a43a06netty-codec-http-4.1.56.Final.jar;C:UsersCast.gradlecachesmodules-2files-2.1io.nettynetty-handler4.1.56.Final6a3ccbc2c9d0b462643a1904ae6cdb84169546netty-handler-4.1.56.Final.jar;C:UsersCast.gradlecachesmodules-2files-2.1io.nettynetty-codec-socks4.1.56.Final6bda6496c20c477d475e63934571eebdd07560e1netty-codec-socks-4.1.56.Final.jar;C:UsersCast.gradlecachesmodules-2files-2.1io.nettynetty-codec4.1.56.Final2d828cca651f2a37de5735f0d79cbe77228c9d21netty-codec-4.1.56.Final.jar;C:UsersCast.gradlecachesmodules-2files-2.1io.nettynetty-transport4.1.56.Final8809fc38a761463f2f43032918e9d455a622f6benetty-transport-4.1.56.Final.jar;C:UsersCast.gradlecachesmodules-2files-2.1io.nettynetty-buffer4.1.56.Final92466b8de0e325a906c53bbaa9585091ef22001dnetty-buffer-4.1.56.Final.jar;C:UsersCast.gradlecachesmodules-2files-2.1io.nettynetty-common4.1.56.Final8e4888cfc66b7ec5a9fb291d9593511481274089netty-common-4.1.56.Final.jar;C:UsersCast.gradlecachesmodules-2files-2.1io.micronaut.grpcmicronaut-grpc-annotation2.2.0cecd044579bcbb555bea1f74becc172df8131fd1micronaut-grpc-annotation-2.2.0.jar;C:UsersCast.gradlecachesmodules-2files-2.1org.reactivestreamsreactive-streams1.0.3d9fb7a7926ffa635b3dcaa5049fb2bfa25b3e7d0reactive-streams-1.0.3.jar;C:UsersCast.gradlecachesmodules-2files-2.1com.github.spotbugsspotbugs-annotations4.0.3755cc5d84d32b31beeaf8597181f0fc4eac98e16spotbugs-annotations-4.0.3.jar;C:UsersCast.gradlecachesmodules-2files-2.1io.grpcgrpc-context1.33.15d312ce1acad9869f118f01cef70a1d5ae7657a8grpc-context-1.33.1.jar;C:UsersCast.gradlecachesmodules-2files-2.1com.google.guavafailureaccess1.0.11dcf1de382a0bf95a3d8b0849546c88bac1292c9failureaccess-1.0.1.jar;C:UsersCast.gradlecachesmodules-2files-2.1com.google.guavalistenablefuture9999.0-empty-to-avoid-conflict-with-guavab421526c5f297295adef1c886e5246c39d4ac629listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar;C:UsersCast.gradlecachesmodules-2files-2.1org.checkerframeworkchecker-compat-qual2.5.5435dc33e3019c9f019e15f01aa111de9d6b2b79cchecker-compat-qual-2.5.5.jar;C:UsersCast.gradlecachesmodules-2files-2.1com.google.j2objcj2objc-annotations1.3ba035118bc8bac37d7eff77700720999acd9986dj2objc-annotations-1.3.jar;C:UsersCast.gradlecachesmodules-2files-2.1io.nettynetty-resolver4.1.56.Final548076140d58591265533418529e28c7ebbf8422netty-resolver-4.1.56.Final.jar;C:UsersCast.gradlecachesmodules-2files-2.1com.fasterxml.jackson.modulejackson-module-kotlin2.11.3ad8d29545c5ab0cdd6d49ee38f7ece8d9f772815jackson-module-kotlin-2.11.3.jar;C:UsersCast.gradlecachesmodules-2files-2.1ch.qos.logbacklogback-classic1.2.37c4f3c474fb2c041d8028740440937705ebb473alogback-classic-1.2.3.jar;C:UsersCast.gradlecachesmodules-2files-2.1org.jetbrains.kotlinxkotlinx-coroutines-core1.3.35bac48cf5828e9b006f3b1ef6e37d2a70c2e7321kotlinx-coroutines-core-1.3.3.jar;C:UsersCast.gradlecachesmodules-2files-2.1com.typesafeconfig1.4.119058a07624a87f90d129af7cd9c68bee94535a9config-1.4.1.jar;C:UsersCast.gradlecachesmodules-2files-2.1com.fasterxml.jackson.corejackson-databind2.11.34f7b27416934dc929bb6c2d2c5fe521829e6a4ecjackson-databind-2.11.3.jar;C:UsersCast.gradlecachesmodules-2files-2.1com.fasterxml.jackson.corejackson-annotations2.11.325d4e9c777e7a8805c4a000a8629d3009c779c9bjackson-annotations-2.11.3.jar;C:UsersCast.gradlecachesmodules-2files-2.1ch.qos.logbacklogback-core1.2.3864344400c3d4d92dfeb0a305dc87d953677c03clogback-core-1.2.3.jar;C:UsersCast.gradlecachesmodules-2files-2.1org.codehaus.mojoanimal-sniffer-annotations1.18f7aa683ea79dc6681ee9fb95756c999acbb62f5danimal-sniffer-annotations-1.18.jar;C:UsersCast.gradlecachesmodules-2files-2.1io.grpcgrpc-netty1.33.1db8c0e98533e5b57264dac2ef827661724f2575fgrpc-netty-1.33.1.jar;C:UsersCast.gradlecachesmodules-2files-2.1com.fasterxml.jackson.corejackson-core2.11.3c2351800432bdbdd8284c3f5a7f0782a352aa84ajackson-core-2.11.3.jar;C:UsersCast.gradlecachesmodules-2files-2.1io.grpcgrpc-core1.33.155343c9703cd8a44cc2978b117b0a964d470e263grpc-core-1.33.1.jar;C:UsersCast.gradlecachesmodules-2files-2.1io.perfmarkperfmark-api0.19.02bfc352777fa6e27ad1e11d11ea55651ba93236bperfmark-api-0.19.0.jar;C:UsersCast.gradlecachesmodules-2files-2.1com.google.code.gsongson2.8.69180733b7df8542621dc12e21e87557e8c99b8cbgson-2.8.6.jar;C:UsersCast.gradlecachesmodules-2files-2.1com.google.androidannotations4.1.1.4a1678ba907bf92691d879fef34e1a187038f9259annotations-4.1.1.4.jar com.tolearn.ApplicationKt
13:56:09.732 [main] ERROR io.micronaut.runtime.Micronaut - Error starting Micronaut server: Error instantiating bean of type [io.micronaut.grpc.server.GrpcEmbeddedServer]
Message: kotlin.jvm.internal.FunctionReferenceImpl.<init>(ILjava/lang/Object;Ljava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
Path Taken: new GrpcEmbeddedServer(ApplicationContext applicationContext,ApplicationConfiguration applicationConfiguration,GrpcServerConfiguration grpcServerConfiguration,[ServerBuilder serverBuilder],ApplicationEventPublisher eventPublisher,ComputeInstanceMetadataResolver computeInstanceMetadataResolver,List metadataContributors)
io.micronaut.context.exceptions.BeanInstantiationException: Error instantiating bean of type [io.micronaut.grpc.server.GrpcEmbeddedServer]
Message: kotlin.jvm.internal.FunctionReferenceImpl.<init>(ILjava/lang/Object;Ljava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
Path Taken: new GrpcEmbeddedServer(ApplicationContext applicationContext,ApplicationConfiguration applicationConfiguration,GrpcServerConfiguration grpcServerConfiguration,[ServerBuilder serverBuilder],ApplicationEventPublisher eventPublisher,ComputeInstanceMetadataResolver computeInstanceMetadataResolver,List metadataContributors)
at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:1925)
at io.micronaut.context.DefaultBeanContext.createAndRegisterSingletonInternal(DefaultBeanContext.java:2679)
at io.micronaut.context.DefaultBeanContext.createAndRegisterSingleton(DefaultBeanContext.java:2665)
at io.micronaut.context.DefaultBeanContext.getBeanForDefinition(DefaultBeanContext.java:2337)
at io.micronaut.context.DefaultBeanContext.getBeanInternal(DefaultBeanContext.java:2311)
at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:1245)
at io.micronaut.context.AbstractBeanDefinition.getBeanForConstructorArgument(AbstractBeanDefinition.java:1013)
at io.micronaut.grpc.server.$GrpcEmbeddedServerDefinition.build(Unknown Source)
at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:1898)
at io.micronaut.context.DefaultBeanContext.createAndRegisterSingletonInternal(DefaultBeanContext.java:2679)
at io.micronaut.context.DefaultBeanContext.createAndRegisterSingleton(DefaultBeanContext.java:2665)
at io.micronaut.context.DefaultBeanContext.getBeanForDefinition(DefaultBeanContext.java:2337)
at io.micronaut.context.DefaultBeanContext.getBeanInternal(DefaultBeanContext.java:2311)
at io.micronaut.context.DefaultBeanContext.findBean(DefaultBeanContext.java:1266)
at io.micronaut.context.DefaultBeanContext.findBean(DefaultBeanContext.java:744)
at io.micronaut.context.BeanLocator.findBean(BeanLocator.java:149)
at io.micronaut.runtime.Micronaut.start(Micronaut.java:66)
at com.tolearn.ApplicationKt.main(Application.kt:8)
Caused by: java.lang.NoSuchMethodError: kotlin.jvm.internal.FunctionReferenceImpl.<init>(ILjava/lang/Object;Ljava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
at com.tolearn.endpoint.DemoMoneyServiceGrpcKt$DemoMoneyServiceCoroutineImplBase$bindService$1.<init>(DemoMoneyGrpcKt.kt)
at com.tolearn.endpoint.DemoMoneyServiceGrpcKt$DemoMoneyServiceCoroutineImplBase.bindService(DemoMoneyGrpcKt.kt:90)
at io.grpc.internal.AbstractServerImplBuilder.addService(AbstractServerImplBuilder.java:120)
at io.grpc.internal.AbstractServerImplBuilder.addService(AbstractServerImplBuilder.java:56)
at io.micronaut.grpc.server.GrpcServerBuilder.serverBuilder(GrpcServerBuilder.java:58)
at io.micronaut.grpc.server.$GrpcServerBuilder$ServerBuilder0Definition.build(Unknown Source)
at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:1898)
... 17 common frames omitted
Process finished with exit code 1
Журналы, когда я пытаюсь выполнить gradle, запускаются из командной строки
C:_dtoLearndemo-money>gradle run
> Task :run FAILED
14:43:44.395 [main] ERROR io.micronaut.runtime.Micronaut - Error starting Micronaut server: Error instantiating bean of type [io.micronaut.grpc.server.GrpcEmbeddedServer]
Message: kotlin.jvm.internal.FunctionReferenceImpl.<init>(ILjava/lang/Object;Ljava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
Path Taken: new GrpcEmbeddedServer(ApplicationContext applicationContext,ApplicationConfiguration applicationConfiguration,GrpcServerConfiguration grpcServerConfiguration,[ServerBuilder serverBuilder],ApplicationEventPublisher eventPublisher,ComputeInstanceMetadataResolver computeInstanceMetadataResolver,List metadataContributors)
io.micronaut.context.exceptions.BeanInstantiationException: Error instantiating bean of type [io.micronaut.grpc.server.GrpcEmbeddedServer]
Message: kotlin.jvm.internal.FunctionReferenceImpl.<init>(ILjava/lang/Object;Ljava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
Path Taken: new GrpcEmbeddedServer(ApplicationContext applicationContext,ApplicationConfiguration applicationConfiguration,GrpcServerConfiguration grpcServerConfiguration,[ServerBuilder serverBuilder],ApplicationEventPublisher eventPublisher,ComputeInstanceMetadataResolver computeInstanceMetadataResolver,List metadataContributors)
at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:1925)
at io.micronaut.context.DefaultBeanContext.createAndRegisterSingletonInternal(DefaultBeanContext.java:2679)
at io.micronaut.context.DefaultBeanContext.createAndRegisterSingleton(DefaultBeanContext.java:2665)
at io.micronaut.context.DefaultBeanContext.getBeanForDefinition(DefaultBeanContext.java:2337)
at io.micronaut.context.DefaultBeanContext.getBeanInternal(DefaultBeanContext.java:2311)
at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:1245)
at io.micronaut.context.AbstractBeanDefinition.getBeanForConstructorArgument(AbstractBeanDefinition.java:1013)
at io.micronaut.grpc.server.$GrpcEmbeddedServerDefinition.build(Unknown Source)
at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:1898)
at io.micronaut.context.DefaultBeanContext.createAndRegisterSingletonInternal(DefaultBeanContext.java:2679)
at io.micronaut.context.DefaultBeanContext.createAndRegisterSingleton(DefaultBeanContext.java:2665)
at io.micronaut.context.DefaultBeanContext.getBeanForDefinition(DefaultBeanContext.java:2337)
at io.micronaut.context.DefaultBeanContext.getBeanInternal(DefaultBeanContext.java:2311)
at io.micronaut.context.DefaultBeanContext.findBean(DefaultBeanContext.java:1266)
at io.micronaut.context.DefaultBeanContext.findBean(DefaultBeanContext.java:744)
at io.micronaut.context.BeanLocator.findBean(BeanLocator.java:149)
at io.micronaut.runtime.Micronaut.start(Micronaut.java:66)
at com.tolearn.ApplicationKt.main(Application.kt:8)
Caused by: java.lang.NoSuchMethodError: kotlin.jvm.internal.FunctionReferenceImpl.<init>(ILjava/lang/Object;Ljava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
at com.tolearn.endpoint.DemoMoneyServiceGrpcKt$DemoMoneyServiceCoroutineImplBase$bindService$1.<init>(DemoMoneyGrpcKt.kt)
at com.tolearn.endpoint.DemoMoneyServiceGrpcKt$DemoMoneyServiceCoroutineImplBase.bindService(DemoMoneyGrpcKt.kt:90)
at io.grpc.internal.AbstractServerImplBuilder.addService(AbstractServerImplBuilder.java:120)
at io.grpc.internal.AbstractServerImplBuilder.addService(AbstractServerImplBuilder.java:56)
at io.micronaut.grpc.server.GrpcServerBuilder.serverBuilder(GrpcServerBuilder.java:58)
at io.micronaut.grpc.server.$GrpcServerBuilder$ServerBuilder0Definition.build(Unknown Source)
at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:1898)
... 17 common frames omitted
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':run'.
> Process 'command 'C:JDKsjdk-11.0.6binjava.exe'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 5s
9 actionable tasks: 1 executed, 8 up-to-date
C:_dtoLearndemo-money>
IntelliJ
Я предполагаю, что это проблема с конфликтами версий, но я не могу представить, что попробовать.
Итак, мой прямой вопрос: что я могу попробовать, чтобы исправить эту проблему? Возможное решение может быть связано с тем, что я использую kotlin-stdlib-jdk8: 1.4.10. Если да, что я могу попробовать или, возможно, понизить?
Интересно, что я могу успешно создать приложение, но я получаю ошибку, упомянутую выше, только при попытке выполнить
Ответ №1:
При запуске сборки Gradle (спасибо за предоставление примера проекта!) Появляется предупреждение, которое должно направить вас на правильный путь:
> Task :kaptGenerateStubsKotlin
w: Some JAR files in the classpath have the Kotlin Runtime library bundled into them. This may cause difficult to debug problems if there's a different version of the Kotlin Runtime library in the classpath. Consider removing these libraries from the classpath
w: /home/chriki/.gradle/caches/modules-2/files-2.1/io.grpc/protoc-gen-grpc-kotlin/1.0.0/d6c8cbe29c60b202165593be5244ce43d37378ac/protoc-gen-grpc-kotlin-1.0.0-jdk7.jar: Library has Kotlin runtime bundled into it
Итак, решение состоит в том, чтобы удалить protoc-gen-grpc-kotlin
зависимость из implementation
конфигурации. Другими словами, удалите следующую строку из вашего dependencies
блока:
implementation("io.grpc:protoc-gen-grpc-kotlin:1.0.0:jdk7@jar")
Зависимость здесь не нужна, она указывает на артефакт плагина, который необходим только в компиляции Protobuf. Таким образом, его настройки в protobuf.plugins
(как это уже имеет место) должно быть достаточно.