0

I am using web3j to receive all new transactions as they are added to the blockchain. I am using private blockchain. Here is my code:

    web3j.transactionObservable().subscribe(tx -> {
        System.out.println(tx);
    });

I am getting this exception while executing this code:

rx.exceptions.OnErrorNotImplementedException: null
    at rx.internal.util.InternalObservableUtils$ErrorNotImplementedAction.call(InternalObservableUtils.java:386) ~[rxjava-1.3.1.jar:1.3.1]
    at rx.internal.util.InternalObservableUtils$ErrorNotImplementedAction.call(InternalObservableUtils.java:383) ~[rxjava-1.3.1.jar:1.3.1]
    at rx.internal.util.ActionSubscriber.onError(ActionSubscriber.java:44) ~[rxjava-1.3.1.jar:1.3.1]
    at rx.observers.SafeSubscriber._onError(SafeSubscriber.java:153) ~[rxjava-1.3.1.jar:1.3.1]
    at rx.observers.SafeSubscriber.onError(SafeSubscriber.java:115) ~[rxjava-1.3.1.jar:1.3.1]
    at rx.internal.operators.OnSubscribeFlattenIterable$FlattenIterableSubscriber.checkTerminated(OnSubscribeFlattenIterable.java:300) ~[rxjava-1.3.1.jar:1.3.1]
    at rx.internal.operators.OnSubscribeFlattenIterable$FlattenIterableSubscriber.drain(OnSubscribeFlattenIterable.java:177) ~[rxjava-1.3.1.jar:1.3.1]
    at rx.internal.operators.OnSubscribeFlattenIterable$FlattenIterableSubscriber.onError(OnSubscribeFlattenIterable.java:135) ~[rxjava-1.3.1.jar:1.3.1]
    at rx.internal.operators.OperatorMerge$MergeSubscriber.reportError(OperatorMerge.java:266) ~[rxjava-1.3.1.jar:1.3.1]
    at rx.internal.operators.OperatorMerge$MergeSubscriber.checkTerminate(OperatorMerge.java:818) ~[rxjava-1.3.1.jar:1.3.1]
    at rx.internal.operators.OperatorMerge$MergeSubscriber.emitLoop(OperatorMerge.java:579) ~[rxjava-1.3.1.jar:1.3.1]
    at rx.internal.operators.OperatorMerge$MergeSubscriber.emit(OperatorMerge.java:568) ~[rxjava-1.3.1.jar:1.3.1]
    at rx.internal.operators.OperatorMerge$MergeSubscriber.onError(OperatorMerge.java:276) ~[rxjava-1.3.1.jar:1.3.1]
    at rx.internal.operators.OnSubscribeMap$MapSubscriber.onError(OnSubscribeMap.java:88) ~[rxjava-1.3.1.jar:1.3.1]
    at rx.Observable.unsafeSubscribe(Observable.java:10263) ~[rxjava-1.3.1.jar:1.3.1]
    at rx.internal.operators.OnSubscribeMap.call(OnSubscribeMap.java:48) ~[rxjava-1.3.1.jar:1.3.1]
    at rx.internal.operators.OnSubscribeMap.call(OnSubscribeMap.java:33) ~[rxjava-1.3.1.jar:1.3.1]
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) ~[rxjava-1.3.1.jar:1.3.1]
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) ~[rxjava-1.3.1.jar:1.3.1]
    at rx.Observable.unsafeSubscribe(Observable.java:10256) ~[rxjava-1.3.1.jar:1.3.1]
    at rx.internal.operators.OnSubscribeFlattenIterable.call(OnSubscribeFlattenIterable.java:66) ~[rxjava-1.3.1.jar:1.3.1]
    at rx.internal.operators.OnSubscribeFlattenIterable.call(OnSubscribeFlattenIterable.java:38) ~[rxjava-1.3.1.jar:1.3.1]
    at rx.Observable.subscribe(Observable.java:10352) ~[rxjava-1.3.1.jar:1.3.1]
    at rx.Observable.subscribe(Observable.java:10319) ~[rxjava-1.3.1.jar:1.3.1]
    at rx.Observable.subscribe(Observable.java:10124) ~[rxjava-1.3.1.jar:1.3.1]
    at com.stan.ico.token.listener.EthereumTransactionListener.listenTransaction(EthereumTransactionListener.java:29) ~[classes/:na]
    at com.stan.ico.token.BootStrap.onApplicationEvent(BootStrap.java:57) ~[classes/:na]
    at com.stan.ico.token.BootStrap.onApplicationEvent(BootStrap.java:1) ~[classes/:na]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:167) ~[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:393) ~[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:347) ~[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:883) ~[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:144) ~[spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546) ~[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
    at com.stan.ico.token.StanIcoTokenApplication.main(StanIcoTokenApplication.java:15) [classes/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_131]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_131]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_131]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_131]
    at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-1.5.6.RELEASE.jar:1.5.6.RELEASE]
Caused by: java.lang.NullPointerException: null
    at org.web3j.protocol.core.filters.BlockFilter.process(BlockFilter.java:27) ~[core-2.3.0.jar:na]
    at org.web3j.protocol.core.filters.Filter.run(Filter.java:43) ~[core-2.3.0.jar:na]
    at org.web3j.protocol.rx.JsonRpc2_0Rx.run(JsonRpc2_0Rx.java:73) ~[core-2.3.0.jar:na]
    at org.web3j.protocol.rx.JsonRpc2_0Rx.lambda$ethBlockHashObservable$10(JsonRpc2_0Rx.java:46) ~[core-2.3.0.jar:na]
    at rx.Observable.unsafeSubscribe(Observable.java:10256) ~[rxjava-1.3.1.jar:1.3.1]
    ... 32 common frames omitted
0

I was able to fix this issue by updating web3j version from 2.3.0 to 2.3.1.

From this link : https://github.com/web3j/web3j/issues/152 I was able to figure out the reason for this issue

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.