Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.ClassNotFoundException: kotlin.coroutines.jvm.internal.CoroutineImpl #766

Closed
junixapp opened this issue Oct 28, 2018 · 9 comments

Comments

@junixapp
Copy link

my build.gradle:

buildscript {
    ext.kotlin_version = '1.3.0-rc-190'
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}
apply plugin: "kotlin"
group 'com.lxj'
version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}
dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlin_version}"
    testCompile group: 'junit', name: 'junit', version: '4.12'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.0.0-RC1'
}
compileKotlin {
    kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
    kotlinOptions.jvmTarget = "1.8"
}

my code is:

fun main(args: Array<String>) {

    GlobalScope.launch{
        print("I am from coroutines")
    }
}

the console output:

Exception in thread "main" java.lang.NoClassDefFoundError: kotlin/coroutines/jvm/internal/CoroutineImpl
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at start.AKt.main(a.kt:13)
Caused by: java.lang.ClassNotFoundException: kotlin.coroutines.jvm.internal.CoroutineImpl
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 13 more
@qwwdfsad
Copy link
Member

Is it still a problem with corouines 1.0.0 and Kotlin 1.3?

@EvilBT
Copy link

EvilBT commented Oct 31, 2018

@qwwdfsad yes.

@qwwdfsad
Copy link
Member

Could you please provide a sample project which reproduces the problem?

I've created a project with the same build.gradle (but with version 1.3 and 1.0.0) and it works properly

@tustar
Copy link

tustar commented Oct 31, 2018

Same issue

import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch


fun main(args: Array<String>)  {
    GlobalScope.launch { // launch new coroutine in background and continue
//        delay(1000L) // non-blocking delay for 1 second (default time unit is ms)
        println("World!") // print after delay
    }
    println("Hello,") // main thread continues while coroutine is delayed
    Thread.sleep(2000L) // block main thread for 2 seconds to keep JVM alive
}

@junixapp
Copy link
Author

junixapp commented Oct 31, 2018

it works after I update IDEA kotlin plugin to 1.3 and restart IDEA,before the plugin version is 1.2.65.
image

@tustar
Copy link

tustar commented Nov 1, 2018

@li-xiaojun , It works for me, thanks!

@junixapp junixapp closed this as completed Nov 5, 2018
@Nadim96
Copy link

Nadim96 commented Nov 8, 2018

Updating kotlin to 1.3 and restarting gave me another error (using the quickstart code on https://ktor.io/quickstart/index.html).

adding

implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.0.0-RC1'
to

dependencies {
}

fixed it for me

@dtschmidt
Copy link

@Nadim96 that fixed it for me as well! I should have thought of that but I'm so glad to have found your comment. Thank you!

@kid1412621
Copy link

got this error when using spring webflux corouter (added implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2")
in gradle)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants