2

我从https://github.com/web3j/web3j-spring-boot-starter添加了 web3j 的依赖项

然后创建了一个服务并编写了:

@Service
public class Web3jServiceImpl {

    @Autowired
    private Web3j web3j;

    public void getBlockNumber() {
        logger.debug("get block number method");
        web3j.blockObservable(false).subscribe(block -> {
            logger.debug("block number: {}", block.getBlock().getNumber() + " has just been created");
        }, Throwable::printStackTrace);
    }

  public void getTxInfo(){
    web3j.transactionObservable().subscribe(tx -> {
            logger.debug("transaction info: {}",tx);
   }, Throwable::printStackTrace);
 }
}

当在以太坊的私有区块链中创建任何块时,我正在获取块号,但是在交易中可观察到的BigInteger out of int range异常。

日志是:

com.fasterxml.jackson.databind.JsonMappingException: BigInteger out of int range
 at [Source: org.apache.http.conn.EofSensorInputStream@6f12b9e; line: 1, column: 1770] (through reference chain: org.web3j.protocol.core.methods.response.EthBlock$TransactionObject["v"]) (through reference chain: org.web3j.protocol.core.methods.response.EthBlock["result"]->org.web3j.protocol.core.methods.response.EthBlock$Block["transactions"])
    at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:388)
    at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:348)
    at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.wrapAndThrow(BeanDeserializerBase.java:1600)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:278)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:140)
    at com.fasterxml.jackson.databind.ObjectReader._bind(ObjectReader.java:1583)
    at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:964)
    at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:981)
    at org.web3j.protocol.core.methods.response.EthBlock$ResponseDeserialiser.deserialize(EthBlock.java:562)
    at org.web3j.protocol.core.methods.response.EthBlock$ResponseDeserialiser.deserialize(EthBlock.java:553)
    at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:504)
    at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:104)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:276)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:140)
    at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3814)
    at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2924)
    at org.web3j.protocol.http.HttpService.lambda$getResponseHandler$20(HttpService.java:89)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:223)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:165)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:140)
    at org.web3j.protocol.http.HttpService.send(HttpService.java:67)
    at org.web3j.protocol.core.Request.send(Request.java:69)
    at org.web3j.protocol.core.Request.lambda$observable$8(Request.java:80)
    at rx.Observable.unsafeSubscribe(Observable.java:10142)
    at rx.internal.operators.OperatorMerge$MergeSubscriber.onNext(OperatorMerge.java:248)
    at rx.internal.operators.OperatorMerge$MergeSubscriber.onNext(OperatorMerge.java:148)
    at rx.internal.operators.OnSubscribeMap$MapSubscriber.onNext(OnSubscribeMap.java:77)
    at org.web3j.protocol.core.filters.BlockFilter.process(BlockFilter.java:32)
    at org.web3j.protocol.core.filters.Filter.pollFilter(Filter.java:82)
    at org.web3j.protocol.core.filters.Filter.lambda$run$9(Filter.java:48)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: com.fasterxml.jackson.databind.RuntimeJsonMappingException: BigInteger out of int range
 at [Source: org.apache.http.conn.EofSensorInputStream@6f12b9e; line: 1, column: 1770] (through reference chain: org.web3j.protocol.core.methods.response.EthBlock$TransactionObject["v"])
    at com.fasterxml.jackson.databind.MappingIterator.next(MappingIterator.java:194)
    at org.web3j.protocol.core.methods.response.EthBlock$ResultTransactionDeserialiser.deserialize(EthBlock.java:537)
    at org.web3j.protocol.core.methods.response.EthBlock$ResultTransactionDeserialiser.deserialize(EthBlock.java:520)
    at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:504)
    at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:104)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:276)
    ... 33 more
Caused by: com.fasterxml.jackson.databind.JsonMappingException: BigInteger out of int range
 at [Source: org.apache.http.conn.EofSensorInputStream@6f12b9e; line: 1, column: 1770] (through reference chain: org.web3j.protocol.core.methods.response.EthBlock$TransactionObject["v"])
    at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:277)
    at com.fasterxml.jackson.databind.deser.SettableBeanProperty._throwAsIOE(SettableBeanProperty.java:551)
    at com.fasterxml.jackson.databind.deser.SettableBeanProperty._throwAsIOE(SettableBeanProperty.java:532)
    at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:108)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:276)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:140)
    at com.fasterxml.jackson.databind.MappingIterator.nextValue(MappingIterator.java:277)
    at com.fasterxml.jackson.databind.MappingIterator.next(MappingIterator.java:192)
    ... 38 more
Caused by: java.lang.ArithmeticException: BigInteger out of int range
    at java.math.BigInteger.intValueExact(BigInteger.java:4550)
    at org.web3j.protocol.core.methods.response.Transaction.setV(Transaction.java:220)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:106)
    ... 42 more
4

0 回答 0