title: Kotlin-gRPC: error: incompatible types: NonExistentClass cannot be converted to Annotation @error.NonExistentClass()
body: <p>I downloaded from micronaut.lanch a simple grpc project and I can build it until I add Kotlin gRPC plugin.</p>
  <p>Beyond the changes in build.gradle.kts, there is nothing else than the original scafolded project.</p>
  <p>I edited in build.gradle.kts.</p>
  <p>Firstly, in order to match IntelliJ Kotlin version</p>
  <pre><code>plugins {
      id(&quot;org.jetbrains.kotlin.jvm&quot;) version &quot;1.4.21&quot;
      id(&quot;org.jetbrains.kotlin.kapt&quot;) version &quot;1.4.21&quot;
      id(&quot;org.jetbrains.kotlin.plugin.allopen&quot;) version &quot;1.4.21&quot;
  </code></pre>
  <p>Seconddly, added folder for kotlin grpc proto autogenerated files</p>
  <pre><code>sourceSets {
      main {
          java {
  ...
              srcDirs (&quot;build/generated/source/proto/main/grpckt&quot;)
  </code></pre>
  <p>And finally</p>
  <pre><code>protobuf {
      protoc {
          artifact = &quot;com.google.protobuf:protoc:3.14.0&quot;
      }
      plugins {
          id(&quot;grpc&quot;) {
              artifact = &quot;io.grpc:protoc-gen-grpc-java:1.33.1&quot;
          }
          id(&quot;grpckt&quot;)
              { artifact = &quot;io.grpc:protoc-gen-grpc-kotlin:0.1.2&quot; }
      }
      generateProtoTasks {
          ofSourceSet(&quot;main&quot;).forEach {
              it.plugins {
                  // Apply the &quot;grpc&quot; plugin whose spec is defined above, without options.
                  id(&quot;grpc&quot;)
                  id(&quot;grpckt&quot;)
              }
          }
      }
  }
  </code></pre>
  <p>The result while building either from INtelliJ or straigh from command line is</p>
  <pre><code>C:\_d\toLearn\kafka-proto\build\tmp\kapt3\stubs\main\com\test\KafkaProtoServiceGrpcKt.java:35: error: incompatible types: NonExistentClass cannot be converted to Annotation
      @error.NonExistentClass()
  </code></pre>
  <p>*** edited</p>
  <pre><code>tasks {
      compileKotlin {
          kotlinOptions {
              jvmTarget = &quot;11&quot;
          }
          dependsOn =&quot;generateProto&quot; //how add this ?????
      }
      compileTestKotlin {
          kotlinOptions {
              jvmTarget = &quot;11&quot;
          }
      }
  
  
  }
  </code></pre>
  <p>*** EDIT 2</p>
  <p>I tried another project. I started from scratch and I am stuck on same issue again.</p>
  <p>Here is the build.gradle</p>
  <pre><code>plugins {
      id(&quot;org.jetbrains.kotlin.jvm&quot;) version &quot;1.4.10&quot;
      id(&quot;org.jetbrains.kotlin.kapt&quot;) version &quot;1.4.10&quot;
      id(&quot;org.jetbrains.kotlin.plugin.allopen&quot;) version &quot;1.4.10&quot;
      id(&quot;com.github.johnrengelman.shadow&quot;) version &quot;6.1.0&quot;
      id(&quot;io.micronaut.application&quot;) version &quot;1.2.0&quot;
      id(&quot;com.google.protobuf&quot;) version &quot;0.8.13&quot;
  }
  
  version = &quot;0.1&quot;
  group = &quot;com.tolearn&quot;
  
  repositories {
      mavenCentral()
      jcenter()
  }
  
  micronaut {
      testRuntime(&quot;junit5&quot;)
      processing {
          incremental(true)
          annotations(&quot;com.tolearn.*&quot;)
      }
  }
  
  //https://stackoverflow.com/a/55646891/4148175
  //kapt {
  //    correctErrorTypes true
  //}
  
  dependencies {
  
      //implementation(&quot;io.grpc:protoc-gen-grpc-kotlin:1.0.0&quot;)
  
      implementation(&quot;io.micronaut:micronaut-validation&quot;)
      implementation(&quot;org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlinVersion}&quot;)
      implementation(&quot;org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}&quot;)
      implementation(&quot;io.micronaut.kotlin:micronaut-kotlin-runtime&quot;)
      implementation(&quot;io.micronaut:micronaut-runtime&quot;)
      implementation(&quot;io.micronaut.grpc:micronaut-grpc-runtime&quot;)
      implementation(&quot;javax.annotation:javax.annotation-api&quot;)
      implementation(&quot;io.micronaut:micronaut-http-client&quot;)
      implementation(&quot;io.micronaut:micronaut-tracing&quot;)
  
      runtimeOnly(&quot;io.jaegertracing:jaeger-thrift&quot;)
      runtimeOnly(&quot;ch.qos.logback:logback-classic&quot;)
      runtimeOnly(&quot;com.fasterxml.jackson.module:jackson-module-kotlin&quot;)
  }
  
  
  application {
      mainClass.set(&quot;com.tolearn.ApplicationKt&quot;)
  }
  
  java {
      sourceCompatibility = JavaVersion.toVersion(&quot;11&quot;)
  }
  
  tasks {
      compileKotlin {
          kotlinOptions {
              jvmTarget = &quot;11&quot;
          }
          dependsOn ':generateProto'
      }
      compileTestKotlin {
          kotlinOptions {
              jvmTarget = &quot;11&quot;
          }
      }
  
  
  }
  
  sourceSets {
      main {
          java {
              srcDirs(&quot;build/generated/source/proto/main/grpc&quot;)
              srcDirs 'build/generated/source/proto/main/grpckt'
              srcDirs(&quot;build/generated/source/proto/main/java&quot;)
          }
      }
  }
  
  protobuf {
      protoc { artifact = &quot;com.google.protobuf:protoc:3.14.0&quot; }
      plugins {
          grpc { artifact = &quot;io.grpc:protoc-gen-grpc-java:1.33.1&quot; }
          grpckt { artifact = &quot;io.grpc:protoc-gen-grpc-kotlin:1.0.0:jdk7@jar&quot;}
      }
      generateProtoTasks {
          all()*.plugins {
              grpc {}
              grpckt {}
          }
      }
  }
  </code></pre>
  <p>The issue is raised on autogenerated stub</p>
  <p><a href="https://i.stack.imgur.com/s1OH7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/s1OH7.png" alt="IntelliJ" /></a></p>
  <p>Here is the full code <a href="https://github.com/jimisdrpc/demo-grpc-jaeger.git" rel="nofollow noreferrer">github</a></p>