getting invalid format exception by making java based rpc call.

+1 vote
Hello everyone. I am trying to connect to the multichain by using this java library https://github.com/priiduneemre/btcd-cli4j.

But Iam getting this error

JsonRpcLayerException(super=CommunicationException(super=com.neemre.btcdcli4j.core.jsonrpc.JsonRpcLayerException: Error #1006001: An unknown exception ocurred while mapping the JSON content., code=1006001))
    at com.neemre.btcdcli4j.core.jsonrpc.JsonMapper.mapToEntity(JsonMapper.java:73)
    at com.neemre.btcdcli4j.core.client.BtcdClientImpl.getInfo(BtcdClientImpl.java:324)
    at com.neemre.btcdcli4j.core.client.BtcdClientImpl.<init>(BtcdClientImpl.java:59)
    at com.mycompany.multichainclient.MultichainClient.main(MultichainClient.java:52)
Caused by: com.fasterxml.jackson.databind.exc.InvalidFormatException: Can not construct instance of int from String value '1.0 alpha 16': not a valid Integer value
 at [Source: {"version":"1.0 alpha 16","protocolversion":10003,"chainname":"testChain","description":"MultiChain testChain","protocol":"multichain","port":7002,"setupblocks":60,"nodeaddress":"testChain@192.168.1.102:7002","burnaddress":"1XXXXXXWUJXXXXXXbtXXXXXXV2XXXXXXWfhaKo","walletversion":60000,"balance":0,"blocks":16,"timeoffset":0,"connections":0,"proxy":"","difficulty":0.00001526,"testnet":true,"keypoololdest":1469357146,"keypoolsize":2,"paytxfee":0,"relayfee":0,"errors":""}; line: 1, column: 2] (through reference chain: com.neemre.btcdcli4j.core.domain.Info["version"])
    at com.fasterxml.jackson.databind.exc.InvalidFormatException.from(InvalidFormatException.java:55)
    at com.fasterxml.jackson.databind.DeserializationContext.weirdStringException(DeserializationContext.java:883)
    at com.fasterxml.jackson.databind.deser.std.StdDeserializer._parseInteger(StdDeserializer.java:411)
    at com.fasterxml.jackson.databind.deser.std.NumberDeserializers$IntegerDeserializer.deserialize(NumberDeserializers.java:289)
    at com.fasterxml.jackson.databind.deser.std.NumberDeserializers$IntegerDeserializer.deserialize(NumberDeserializers.java:271)
    at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:523)
    at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:95)
    at com.fasterxml.jackson.databind.deser.impl.BeanPropertyMap.findDeserializeAndSet(BeanPropertyMap.java:285)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:248)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:136)
    at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3560)
    at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2576)
    at com.neemre.btcdcli4j.core.jsonrpc.JsonMapper.mapToEntity(JsonMapper.java:68)
    ... 3 more

I
asked Jul 24, 2016 by Furqan Hasan

1 Answer

0 votes

It looks like this library is assuming that the version field of the response from getinfo can be converted to a number, whereas MultiChain's response includes the word "alpha" which breaks this conversion. If you poke around inside the library you should be able to disable whatever is triggering this problem (see the stack trace at the start of the error report) or possible change the internal class definitions so that version can be a string.

answered Jul 25, 2016 by MultiChain
...