Closed Fredzzzz closed 6 years ago
Hi @Fredzzzz, thank you for your enthusiasm!
Firstly, seems like that Scala is currently not supported in JDK9 , so I am afraid you have to stick with JDK8.
Regarding your issue, the warnings should not be a problem. Can you attach the code that causes the exception?
Hi @stefanolande , of course. Sorry, I actually forgot that yesterday. My bad. This exception occurs whenever I run any of the scala code samples in https://github.com/bitbart/blockchain-analytics-api/tree/master/src/main/scala/tcs/examples/bitcoin/mongo
For example:
package tcs.examples.bitcoin.mongo
import tcs.blockchain.BlockchainLib
import tcs.blockchain.bitcoin.{BitcoinSettings, MainNet}
import tcs.db.DatabaseSettings
import tcs.mongo.Collection
/**
* Created by stefano on 13/06/17.
*/
object MyBlockchain {
def main(args: Array[String]): Unit = {
val blockchain = BlockchainLib.getBitcoinBlockchain(new BitcoinSettings("user", "password", "8332", MainNet))
val mongo = new DatabaseSettings("myDatabase")
val myBlockchain = new Collection("myBlockchain", mongo)
blockchain.foreach(block => {
block.bitcoinTxs.foreach(tx => {
myBlockchain.append(List(
("txHash", tx.hash),
("blockHash", block.hash),
("date", block.date),
("inputs", tx.inputs),
("outputs", tx.outputs)
))
})
})
myBlockchain.close
}
}
Hi @Fredzzzz, now the issue should be solved. Could you run your code again?
It worked! The above MyBlockchain.scala code now runs through. Thanks for the prompt fix. I will play around with the rest in a bit. Much appreciated your help here @stefanolande ! Cheers
Hi guys,
first of all, THANKS for building this to facilitate Analytics on the blockchain! I am trying to build this for a few weeks now following your instructions and am encountering an issue that I am unable to resolve: Exception in thread "main" java.lang.ClassCastException: tcs.blockchain.bitcoin.BitcoinInput cannot be cast to scala.Tuple2
The detailed Runtime Warnings and Exceptions are below.
Could it be that based on the system specifications below my build results in missing generics for Java Collection classes like HashMap, ArrayList, Vector or Hashtable or type-safety being insufficient? I am a bit lost here and would appreciate some help.
This can be resolved by building with Java 8 instead (which seems to be the common fix from what I read online) - For the sake of completeness, I attached the complete log file for this initial Java 9 error if that helps since it is the reason that forced me to build with Java 8 in the first place. I am unsure whether it is related to my current problem or not?
Thanks so much. Fred
System Specifications: ProductName: Mac OS X ProductVersion: 10.12.6 BuildVersion: 16G29 Uname: Darwin Kernel Version 16.7.0 Arch: i386 Machine: x86_64 Apache Maven: Version 3.5.2 java: jdk1.8.0_152 sbt: sbt version 1.0.3 built against Scala 2.12.4 mongoDB version: v3.4.10 OpenSSL version: OpenSSL 1.0.2m
IDE used: IntelliJ IDEA 2017.2.5 Build #IU-172.4343.14 JRE: 1.8.0_152-release-915-b12 x86_64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Mac OS X 10.12.6
Runtime Warnings and Exceptions:
Dec 08, 2017 9:07:58 PM org.bitcoinj.core.Context getOrCreate WARNING: Implicitly creating context. This is a migration step and this message will eventually go away. Dec 08, 2017 9:07:58 PM org.bitcoinj.core.Context
INFO: Creating bitcoinj 0.15-SNAPSHOT context.
Dec 08, 2017 9:08:03 PM org.bitcoinj.core.PeerGroup startAsync
WARNING: Starting up with no attached block chain. Did you forget to pass one to the constructor?
Dec 08, 2017 9:08:03 PM org.bitcoinj.core.PeerGroup$8 run
INFO: Starting ...
Dec 08, 2017 9:08:03 PM org.bitcoinj.core.PeerGroup$6 go
INFO: Localhost peer detected, trying to use it instead of P2P discovery
Dec 08, 2017 9:08:03 PM org.bitcoinj.core.PeerGroup connectTo
INFO: Attempting connection to [127.0.0.1]:8333 (0 connected, 1 pending, 0 max)
Dec 08, 2017 9:08:03 PM org.bitcoinj.core.PeerGroup connectTo
INFO: Attempting connection to [192.168.0.6]:8333 (0 connected, 2 pending, 2 max)
Dec 08, 2017 9:08:03 PM org.bitcoinj.net.NioClientManager handleKey
INFO: Connected to /127.0.0.1:8333
Dec 08, 2017 9:08:03 PM org.bitcoinj.core.Peer connectionOpened
INFO: Announcing to /127.0.0.1:8333 as: /bitcoinj:0.15-SNAPSHOT/
Dec 08, 2017 9:08:03 PM org.bitcoinj.net.NioClientManager handleKey
INFO: Connected to My-MacBook-Pro.local/192.168.0.6:8333
Dec 08, 2017 9:08:03 PM org.bitcoinj.core.Peer connectionOpened
INFO: Announcing to My-MacBook-Pro.local/192.168.0.6:8333 as: /bitcoinj:0.15-SNAPSHOT/
Dec 08, 2017 9:08:03 PM org.bitcoinj.core.Peer processVersionMessage
INFO: [127.0.0.1]:8333: Got version=70015, subVer='/Satoshi:0.15.1/', services=0x13, time=2017-12-08 21:08:01, blocks=498277
Dec 08, 2017 9:08:03 PM org.bitcoinj.core.PeerGroup handleNewPeer
INFO: [127.0.0.1]:8333: New peer (1 connected, 1 pending, 2 max)
Dec 08, 2017 9:08:03 PM org.bitcoinj.core.PeerGroup setDownloadPeer
INFO: Setting download peer: [127.0.0.1]:8333
Dec 08, 2017 9:08:03 PM org.bitcoin.Secp256k1Context
INFO: java.lang.UnsatisfiedLinkError: no secp256k1 in java.library.path
Dec 08, 2017 9:08:03 PM org.bitcoinj.core.Peer processVersionMessage
INFO: [192.168.0.6]:8333: Got version=70015, subVer='/Satoshi:0.15.1/', services=0x13, time=2017-12-08 21:08:01, blocks=498277
Dec 08, 2017 9:08:03 PM org.bitcoinj.core.PeerGroup handleNewPeer
INFO: [192.168.0.6]:8333: New peer (2 connected, 0 pending, 2 max)
Dec 08, 2017 9:08:03 PM org.bitcoinj.core.Peer processMessage
WARNING: [127.0.0.1]:8333: Received unhandled message: org.bitcoinj.core.SendHeadersMessage@bf3748a
Dec 08, 2017 9:08:03 PM org.bitcoinj.core.Peer processMessage
WARNING: [192.168.0.6]:8333: Received unhandled message: org.bitcoinj.core.SendHeadersMessage@1c9c201f
Dec 08, 2017 9:08:09 PM com.mongodb.diagnostics.logging.SLF4JLogger info
INFO: Cluster created with settings {hosts=[127.0.0.1:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
Dec 08, 2017 9:08:09 PM com.mongodb.diagnostics.logging.SLF4JLogger info
INFO: Opened connection [connectionId{localValue:1, serverValue:12}] to 127.0.0.1:27017
Dec 08, 2017 9:08:09 PM com.mongodb.diagnostics.logging.SLF4JLogger info
INFO: Monitor thread successfully connected to server with description ServerDescription{address=127.0.0.1:27017, type=STANDALONE, state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 4, 10]}, minWireVersion=0, maxWireVersion=5, maxDocumentSize=16777216, roundTripTimeNanos=948792}
Dec 08, 2017 9:08:09 PM org.bitcoinj.core.Peer getBlock
INFO: Request to fetch block 00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048
Exception in thread "main" java.lang.ClassCastException: tcs.blockchain.bitcoin.BitcoinInput cannot be cast to scala.Tuple2
at scala.collection.immutable.List.map(List.scala:272)
at tcs.utils.Convert$.convertPair(Convert.scala:16)
at tcs.mongo.Collection.$anonfun$append$2(Collection.scala:31)
at scala.collection.immutable.List.map(List.scala:276)
at tcs.mongo.Collection.append(Collection.scala:31)
at tcs.examples.bitcoin.mongo.MyBlockchain$.$anonfun$main$2(MyBlockchain.scala:26)
at tcs.examples.bitcoin.mongo.MyBlockchain$.$anonfun$main$2$adapted(MyBlockchain.scala:20)
at scala.collection.immutable.List.foreach(List.scala:378)
at tcs.examples.bitcoin.mongo.MyBlockchain$.$anonfun$main$1(MyBlockchain.scala:20)
at tcs.examples.bitcoin.mongo.MyBlockchain$.$anonfun$main$1$adapted(MyBlockchain.scala:19)
at tcs.blockchain.bitcoin.BitcoinBlockchain.foreach(BitcoinBlockchain.scala:75)
at tcs.examples.bitcoin.mongo.MyBlockchain$.main(MyBlockchain.scala:19)
at tcs.examples.bitcoin.mongo.MyBlockchain.main(MyBlockchain.scala)
Process finished with exit code 1
Error Log when building with Java 9.txt