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

subscribe: NoSuchMethodError #8

Closed
sghpjuikit opened this issue Aug 19, 2014 · 10 comments
Closed

subscribe: NoSuchMethodError #8

sghpjuikit opened this issue Aug 19, 2014 · 10 comments

Comments

@sghpjuikit
Copy link

Hi,

I have come across the following exception:

Caused by: java.lang.NoSuchMethodError: org.reactfx.EventStreamBase.subscribe(Ljava/lang/Object;)Lorg/reactfx/Subscription;
at org.reactfx.BiEventSource.subscribe(BiEventSource.java:5)

here is my code:

BiEventSource<Metadata,Metadata> itemUpdateES = new BiEventSource();

public Subscription subscribeToUpdates(BiConsumer<Metadata, Metadata> bc) {
return itemUpdateES.subscribe(bc);
}

another exception that seems to have the same cause is:

Caused by: java.lang.NoSuchMethodError: org.reactfx.MappedBiStream.subscribeToBi(Lorg/reactfx/BiEventStream;Ljava/util/function/BiConsumer;)Lorg/reactfx/Subscription;
at org.reactfx.MappedBiStream.subscribeToInputs(MappedStream.java:46)
at org.reactfx.LazilyBoundStream.firstSubscriber(LazilyBoundStream.java:17)
at org.reactfx.EventStreamBase.subscribe(EventStreamBase.java:35)
at org.reactfx.EventStreams$StreamBoundValueImpl.(EventStreams.java:689)
at org.reactfx.EventStreams.toObservableValue(EventStreams.java:544)
at org.reactfx.EventStream.toObservableValue(EventStream.java:72)

thrown when used toObservableValue() on an event stream that is a result of :
itemUpdateES.map((ov,nv)->nv).toObservableValue(value)

Any thoughts?

It looks like a problem with BiEventStreamBase implementation. I know i can always use BiTouple, but id rather not.

Or am doing something wrong? Not sure why it is looking for subscribe(Object). Should the parameter not be a BiConsumer?

edit: the problem turns out to be outdated .jar in the download section. Using the sources.jar directly does not cause any problems. The method toObservable() was apparently renamed to toBinding().

@TomasMikula
Copy link
Owner

I noticed that you omitted any type parameters from BiEventSource and BiConsumer. This is likely the cause of your problem. Specify the type parameters and please report back if it resolved your problem.

@sghpjuikit
Copy link
Author

I omitted the generic parameter as i didnt believe it was relevant here. Im using my own object Metadata.

But, something like this is what compiler would complain about. I dont see how one can get NoSuchmethodError from using raw type instead of generic one. It only happens to me when i dont recompile whole project and some classes become outdated.

Have you read the edit at the end of my post? Using your source files inside my project solves the problem. It really looks like problem with the library jar. In fact the jar and source-files jar are clearly not of the same version, since some one contains toObservable, while the other has toBinding().

I will try to use the library one more time and play around (and also dig into the source code now that i have access to it (library can not show it since it would be compiled)), but i dont think it is problem on my side, particularly if the same code works with other version of your sources.

@TomasMikula
Copy link
Owner

Just tested the following code with reactfx-1.3.jar with no exception:

import java.util.function.BiConsumer;
import org.reactfx.BiEventSource;
import org.reactfx.Subscription;

public class Test {

    BiEventSource itemUpdateES = new BiEventSource();

    public static void main(String[] args) {
        new Test().subscribeToUpdates(
                (a, b) -> System.out.println("bi-event"));
        System.out.println("DONE");
    }

    public Subscription subscribeToUpdates(BiConsumer bc) {
        return itemUpdateES.subscribe(bc);
    }
}

Can you provide code to reproduce the problem?

@TomasMikula
Copy link
Owner

And reactfx-1.3.jar does not contain toObservableValue() anymore.

@sghpjuikit
Copy link
Author

Allright let me check things on my end, because, mine, strangely enough, does. Maybe i got a wrong jar or something.

As for the code, im not sure. Ill try to figure things out first and then tell you, so to not waste your time with testing. Ill inform you as soon as i reach an understanding.

My hunch is telling me i accidentally linked to the old jar (from some time ago) when imported the new one yesterday.

Thx for quick feedback anyway.

@sghpjuikit
Copy link
Author

link:
https://oss.sonatype.org/content/repositories/snapshots/org/reactfx/reactfx/1.3.1-SNAPSHOT/
file:
reactfx-1.3.1-20140711.184616-1.jar Fri Jul 11 13:46:23 CDT 2014 302527

This jar does not contain toBinding() method, but toObservableValue() for me and produces the aforementioned errors.

Am i using wrong file? Can you link me to the reactfx-1.3.jar you speak of? The one im using is 1.3.1 from download page.

As for the test code:

BiEventSource itemUpdateES = new BiEventSource();
itemUpdateES.subscribe((a, b) -> System.out.println("bi-event"));

this causes the same error for me if i use the jar i downloaded. If i download sources.jar and extract the files into my project everything is fine.

@TomasMikula
Copy link
Owner

I just checked and the JAR you linked seems to contain toBinding() and not toObservableValue().

This code does not compile:

import org.reactfx.EventSource;

public class Test {
    public void test() {
        new EventSource<String>().toObservableValue(null);
    }
}
$ javac -cp reactfx-1.3.1-20140711.184616-1.jar Test.java 
Test.java:5: error: cannot find symbol
        new EventSource<String>().toObservableValue(null);
                                 ^
  symbol:   method toObservableValue(<null>)
  location: class EventSource<String>
1 error

This code compiles:

import org.reactfx.EventSource;

public class Test {
    public void test() {
        new EventSource<String>().toBinding(null);
    }
}

@sghpjuikit
Copy link
Author

I found the problem.

I found out, that i had older ReactFX library linked to Netbeans, it probably overrode this new one. But i removed it and i still was not able to fix this.

Eventually i discovered, that there is yet another instance of the ReactFX library packaged with LiveDirs library (from you). Naturally, it is an older version and it overrode the one i was importing.

I must have grabbed the liveDirs version with dependencies included. It looks dangerous to me to do that now.

That took a while... Phew. Everything is ok now.
Thank you for the tests anyway. That was really quick from you.

@TomasMikula
Copy link
Owner

Yeah, it's best to let Maven or Gradle take care of the dependencies.

@sghpjuikit
Copy link
Author

Thx for the tip. I should look into those.

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

2 participants