kotlin-debug-adapter icon indicating copy to clipboard operation
kotlin-debug-adapter copied to clipboard

NoClassDefFound when trying to debug using default generated launch.json

Open Strum355 opened this issue 6 years ago • 4 comments

Using Ktor web server with the following main


@UseExperimental(KtorExperimentalAPI::class)
fun main(args: Array<String>) {
    val server = embeddedServer(CIO, 8080, module = Application::module)
    server.start(wait = true)
}

image

Strum355 avatar Oct 01 '19 12:10 Strum355

@Strum355 I've transferred the issue to kotlin-debug-adapter, since that is where the debug functionality is implemented.

This looks like a bug with the dependency resolution. Did you run a ./gradlew build before starting the debug session?

fwcd avatar Oct 02 '19 15:10 fwcd

For reproduce this bug :

  1. mkdir abc && cd abc
  2. gradle init (select application-kotlin-kotlin-dsl)
  3. ./gradlew build
  4. open VSCode and run debbuger; (not forget change class name) And....we have the bug

What we can do? If replace implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") to implementation("org.jetbrains.kotlin:kotlin-stdlib") it can help.

info

------------------------------------------------------------
Gradle 5.6.2
------------------------------------------------------------
Build time:   2019-09-05 16:13:54 UTC
Revision:     55a5e53d855db8fc7b0e494412fc624051a8e781
Kotlin:       1.3.41
Groovy:       2.5.4
Ant:          Apache Ant(TM) version 1.9.14 compiled on March 12 2019
JVM:          1.8.0_201 (Oracle Corporation 25.201-b09)
OS:           Linux 5.1.16-050116-generic amd64

jershell avatar Nov 20 '19 10:11 jershell

Any update on this?

It seems to me that changing this line to implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8' will fix the issue.

hasali19 avatar Jan 23 '20 23:01 hasali19

I'm reproducing this issue with the following configuration, it might be related to ktor ? 🤔

plugins {
    id 'org.jetbrains.kotlin.jvm' version "$kotlin_version"
	id 'application'
}
mainClassName = 'io.ktor.server.netty.EngineMain' // Starting with 1.0.0-beta-3
sourceCompatibility = 1.8
targetCompatibility = 1.8
compileKotlin { kotlinOptions.jvmTarget = "1.8" }
compileTestKotlin { kotlinOptions.jvmTarget = "1.8" }

repositories {
    mavenCentral()
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
    implementation "io.ktor:ktor-server-netty:$ktor_version"
    compile "ch.qos.logback:logback-classic:1.2.3"
    testCompile group: 'junit', name: 'junit', version: '4.12'
}

sourceSets {
    main.kotlin.srcDirs = [ 'src/main/kotlin' ]
    main.resources.srcDirs = [ 'src/main/resources' ]
}

Update: I seemed to fix the NoClassDefFound by using JDK 8

vinniehg avatar Mar 28 '20 14:03 vinniehg