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

RxJava Maven dependency scope=runtime but is required for compilation #730

Closed
patrickconant opened this issue Mar 26, 2015 · 14 comments
Closed

Comments

@patrickconant
Copy link

I've encountered this issue, but don't know enough about Gradle to help diagnose the issue. In versions of Hystrix prior to 1.4, the Maven dependency on io.reactivex:rxjava had scope=compile (see pom.xml in Maven Central). With version 1.4 and later, the Maven dependency scope is set to "runtime" (pom.xml in Maven Central). This causes Maven-based java compilation failures of projects that depend on Hystrix 1.4 or greater. In my case, the compilation error message is 'cannot access rx.Observable class file for rx.Observable not found'.

It doesn't appear that anything has changed in the hystrix-core/build.gradle file -- the dependency looks right ("compile 'io.reactivex:rxjava:1.0.7'"). But something appears to have changed in how Gradle translates that into the maven pom.xml that's published to Maven Central.

There is a work-around for users running into this issue -- one can simply add a compile-time dependency on rxjava to their own project. That makes using Hystrix a bit more complicated and isn't standard handling for library dependencies.

@mattrjacobs
Copy link
Contributor

Thanks for the report @patrickconant . This was not an intentional change - I'll have to track down what's causing this - not sure off the top of my head.

@mattrjacobs
Copy link
Contributor

@patrickconant / @axiak Looks like the switch to Nebula publishing broke this piece of the pom. This bug exists in 1.4.0/1.4.1/1.4.2.

Also see ReactiveX/RxNetty#292 for another example of this.

I've notified the Nebula owners and they have already got this in their list of fixes coming shortly.

As soon as that occurs, I'll do a release to pick up that change.

Until then, the only workaround is to explicitly depend on all Hystrix dependencies yourself :(

For hystrix-core, this should be archauis-core + rxjava + slf4j-api

@axiak
Copy link
Contributor

axiak commented Mar 26, 2015

Thanks for looking into it.. looks like we're going to ship a shaded version internally :(

@axiak
Copy link
Contributor

axiak commented Mar 26, 2015

FYI this is what we're using to ship our own corrected version of 1.4.2: https://git.hubteam.com/gist/maxiak/e88ec3c5997d3eabf374

@mattrjacobs
Copy link
Contributor

FWIW, here's the nebula issue: nebula-plugins/nebula-publishing-plugin#31

@spencergibb
Copy link
Contributor

why would you need to publish your own version? Don't you just need a pom with the right dependencies? That's what we're doing for spring-cloud-netflix.

@axiak
Copy link
Contributor

axiak commented Mar 26, 2015

@spencergibb it depends on who you're solving for. we have hundreds of projects that depend on hystrix that I'm trying to upgrade to a single new version.

@juristr
Copy link

juristr commented Apr 1, 2015

For others, I got it to work with this Maven configuration:

<dependency>
    <groupId>com.netflix.hystrix</groupId>
    <artifactId>hystrix-core</artifactId>
    <version>1.4.3</version>
</dependency>
<dependency>
    <groupId>com.netflix.archaius</groupId>
    <artifactId>archaius-core</artifactId>
    <version>0.4.1</version>
</dependency>
<dependency>
    <groupId>io.reactivex</groupId>
    <artifactId>rxjava</artifactId>
    <version>1.0.7</version>
    <scope>compile</scope>
</dependency>
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
    <version>1.7.0</version>
</dependency>

@mhuisman
Copy link

This issue persists in version 1.4.7, fix above still applies

@taringamberini
Copy link

This issue persists in version 1.4.10.

As previously suggested by @juristr excplicitly declare compile scope in order to get your project compiled:

<dependency>
    <groupId>io.reactivex</groupId>
    <artifactId>rxjava</artifactId>
    <version>${rxjava_version_requested_by_hystrix-core_x_y_z}</version>
    <scope>compile</scope>
</dependency>

@jmaasing
Copy link

jmaasing commented Sep 4, 2015

This issue persists in version 1.4.14

@chanwookpark
Copy link

Hi. Is this issue patched?
I meet this error 'cannot access rx.Observable. class file for rx.Observable not found"
I'm using 1.4.14 Hystrix.
thanks you.

@aminjava
Copy link

Adding this dependency fixed the build for me

<dependency>
        <groupId>io.reactivex</groupId>
        <artifactId>rxjava</artifactId>
        <version>1.0.8</version>
    </dependency>

@mattrjacobs
Copy link
Contributor

This should be fixed with #944 and available in the next release

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

No branches or pull requests

10 participants