Why I am getting NoClassDefFoundError: org/reactivestreams/Publisher
11,404
Solution 1
The exception means that the class org.reactivestreams.Publisher is not available at runtime. So it is missing in the classpath. You can add to the classpath, by adding the dependency-reference in gradle.
Depending on your used version it should look like:
dependencies {
compile group: 'org.reactivestreams', name: 'reactive-streams', version: '1.0.0'
...<the other depandancies>...
}
Solution 2
I got this exception using org.springframework.test.web.reactive.server.WebTestClient so it's easy to fix with spring-boot, just adding this dependency to your pom.xml (for maven projects):
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
Comments
-
sakhunzai almost 2 years
Stream.java
import io.reactivex.*; public class Stream { public static void main(String args[]) { Observable.just("Howdy!").subscribe(System.out::println); } }
build.gradle:
group 'com.sakhunzai' version '1.0-SNAPSHOT' apply plugin: 'java' sourceCompatibility = JavaVersion.VERSION_1_8 repositories { mavenCentral() } dependencies { compile 'io.reactivex.rxjava2:rxjava:2.0.5' testCompile group: 'junit', name: 'junit', version: '4.11' }
Exception:
Exception in thread "main" java.lang.NoClassDefFoundError: org/reactivestreams/Publisher .... Caused by: java.lang.ClassNotFoundException: org.reactivestreams.Publisher
I am following the tutorial at page six, except I decided to use gradle instead of maven
Edit
Probably some issue with gradle and Intellij IDEA
Following fixed the issue: settings.gradle:
rootProject.name = 'JavaRx' include "buildSrc"