Exception thrown: java.lang.ClassNotFoundException: org.reactivestreams.Publisher

In a JavaFX Gradle application I am developing using RxJava and Kotlin in IntelliJ IDEA 2017.1.2 (Build # IC-171.4249.39), I am getting an exception:

Exception in JavaFX Application Theme stream java.lang.NoClassDefFoundError: org / reactivestreams / Publisher

every time like this code

return Completable.complete()

      

Performed

... Following a suggestion from a similar question Why am I getting NoClassDefFoundError: org / reactivestreams / Publisher , I tried to add the included reactive streams to dependencies

my build.gradle

script block

dependencies {
    compile 'org.jetbrains.kotlin:kotlin-stdlib:1.1.2'
    compile 'org.reactivestreams:reactive-streams:1.0.0'
    compile 'io.reactivex.rxjava2:rxkotlin:2.0.0'
}

      

but the problem persists. The dependency tree looks like this:

compile - Dependencies for source set 'main' (deprecated, use 'implementation ' instead).
+--- org.jetbrains.kotlin:kotlin-stdlib:1.1.2
|    \--- org.jetbrains:annotations:13.0
+--- org.reactivestreams:reactive-streams:1.0.0
\--- io.reactivex.rxjava2:rxkotlin:2.0.0
     +--- io.reactivex.rxjava2:rxjava:2.0.7
     |    \--- org.reactivestreams:reactive-streams:1.0.0
     \--- org.jetbrains.kotlin:kotlin-stdlib:1.1.0 -> 1.1.2 (*)

compileClasspath - Compile classpath for source set 'main'.
+--- org.jetbrains.kotlin:kotlin-stdlib:1.1.2
|    \--- org.jetbrains:annotations:13.0
+--- org.reactivestreams:reactive-streams:1.0.0
\--- io.reactivex.rxjava2:rxkotlin:2.0.0
     +--- io.reactivex.rxjava2:rxjava:2.0.7
     |    \--- org.reactivestreams:reactive-streams:1.0.0
     \--- org.jetbrains.kotlin:kotlin-stdlib:1.1.0 -> 1.1.2 (*)

+--- org.jetbrains.kotlin:kotlin-stdlib:1.1.2
|    \--- org.jetbrains:annotations:13.0
+--- org.reactivestreams:reactive-streams:1.0.0
\--- io.reactivex.rxjava2:rxkotlin:2.0.0
     +--- io.reactivex.rxjava2:rxjava:2.0.7
     |    \--- org.reactivestreams:reactive-streams:1.0.0
     \--- org.jetbrains.kotlin:kotlin-stdlib:1.1.0 -> 1.1.2 (*)

\--- org.jetbrains.kotlin:kotlin-annotation-processing:1.1.2
     \--- org.jetbrains.kotlin:kotlin-stdlib:1.1.2
          \--- org.jetbrains:annotations:13.0

kaptTest
\--- org.jetbrains.kotlin:kotlin-annotation-processing:1.1.2
     \--- org.jetbrains.kotlin:kotlin-stdlib:1.1.2
          \--- org.jetbrains:annotations:13.0

runtime - Runtime dependencies for source set 'main' (deprecated, use 'runtimeOnly ' instead).
+--- org.jetbrains.kotlin:kotlin-stdlib:1.1.2
|    \--- org.jetbrains:annotations:13.0
+--- org.reactivestreams:reactive-streams:1.0.0
\--- io.reactivex.rxjava2:rxkotlin:2.0.0
     +--- io.reactivex.rxjava2:rxjava:2.0.7
     |    \--- org.reactivestreams:reactive-streams:1.0.0
     \--- org.jetbrains.kotlin:kotlin-stdlib:1.1.0 -> 1.1.2 (*)

runtimeClasspath - Runtime classpath of source set 'main'.
+--- org.jetbrains.kotlin:kotlin-stdlib:1.1.2
|    \--- org.jetbrains:annotations:13.0
+--- org.reactivestreams:reactive-streams:1.0.0
\--- io.reactivex.rxjava2:rxkotlin:2.0.0
     +--- io.reactivex.rxjava2:rxjava:2.0.7
     |    \--- org.reactivestreams:reactive-streams:1.0.0
     \--- org.jetbrains.kotlin:kotlin-stdlib:1.1.0 -> 1.1.2 (*)

testCompile - Dependencies for source set 'test' (deprecated, use 'testImplementation ' instead).
+--- org.jetbrains.kotlin:kotlin-stdlib:1.1.2
|    \--- org.jetbrains:annotations:13.0
+--- org.reactivestreams:reactive-streams:1.0.0
\--- io.reactivex.rxjava2:rxkotlin:2.0.0
     +--- io.reactivex.rxjava2:rxjava:2.0.7
     |    \--- org.reactivestreams:reactive-streams:1.0.0
     \--- org.jetbrains.kotlin:kotlin-stdlib:1.1.0 -> 1.1.2 (*)

testCompileClasspath - Compile classpath for source set 'test'.
+--- org.jetbrains.kotlin:kotlin-stdlib:1.1.2
|    \--- org.jetbrains:annotations:13.0
+--- org.reactivestreams:reactive-streams:1.0.0
\--- io.reactivex.rxjava2:rxkotlin:2.0.0
     +--- io.reactivex.rxjava2:rxjava:2.0.7
     |    \--- org.reactivestreams:reactive-streams:1.0.0
     \--- org.jetbrains.kotlin:kotlin-stdlib:1.1.0 -> 1.1.2 (*)

testRuntime - Runtime dependencies for source set 'test' (deprecated, use 'testRuntimeOnly ' instead).
+--- org.jetbrains.kotlin:kotlin-stdlib:1.1.2
|    \--- org.jetbrains:annotations:13.0
+--- org.reactivestreams:reactive-streams:1.0.0
\--- io.reactivex.rxjava2:rxkotlin:2.0.0
     +--- io.reactivex.rxjava2:rxjava:2.0.7
     |    \--- org.reactivestreams:reactive-streams:1.0.0
     \--- org.jetbrains.kotlin:kotlin-stdlib:1.1.0 -> 1.1.2 (*)

testRuntimeClasspath - Runtime classpath of source set 'test'.
+--- org.jetbrains.kotlin:kotlin-stdlib:1.1.2
|    \--- org.jetbrains:annotations:13.0
+--- org.reactivestreams:reactive-streams:1.0.0
\--- io.reactivex.rxjava2:rxkotlin:2.0.0
     +--- io.reactivex.rxjava2:rxjava:2.0.7
     |    \--- org.reactivestreams:reactive-streams:1.0.0
     \--- org.jetbrains.kotlin:kotlin-stdlib:1.1.0 -> 1.1.2 (*)

      

As you can see, org.reactivestreams: reactive streams are present in every environment.

Now I managed to solve the problem by adding a manual dependency on reactive-streams-1.0.0.jar , but I don't like this solution at all.

Can anyone please advise on a better solution? Thank!

+3


source to share





All Articles