tumblr / colossus

I/O and Microservice library for Scala
Apache License 2.0
1.14k stars 96 forks source link

Binary Incompatibility #525

Closed Mindtoeye closed 7 years ago

Mindtoeye commented 7 years ago

Hoi there,

Been banging my head against the wall for a few days now. I'm trying to get a Colossus microservice running in my Scala application using the example taken directly from the website. I was using an older API and had to switch to the most recent one due to incompatibilities. When I try to run the current version I get the error below in the console. No idea how to interpret this. SBT and source are included below as well.

[ERROR] [08/01/2017 08:34:25.689] [COLOSSUS-akka.actor.default-dispatcher-2] [akka://COLOSSUS/user/iosystem-manager] null
akka.actor.ActorInitializationException: exception during creation
    at akka.actor.ActorInitializationException$.apply(Actor.scala:164)
    at akka.actor.ActorCell.create(ActorCell.scala:596)
    at akka.actor.ActorCell.invokeAll$1(ActorCell.scala:456)
    at akka.actor.ActorCell.systemInvoke(ActorCell.scala:478)
    at akka.dispatch.Mailbox.processAllSystemMessages(Mailbox.scala:279)
    at akka.dispatch.Mailbox.run(Mailbox.scala:220)
    at akka.dispatch.Mailbox.exec(Mailbox.scala:231)
    at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
    at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
    at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
    at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at akka.util.Reflect$.instantiate(Reflect.scala:66)
    at akka.actor.ArgsReflectConstructor.produce(Props.scala:352)
    at akka.actor.Props.newActor(Props.scala:252)
    at akka.actor.ActorCell.newActor(ActorCell.scala:552)
    at akka.actor.ActorCell.create(ActorCell.scala:578)
    ... 9 more
Caused by: java.lang.VerifyError: Bad local variable type
Exception Details:
  Location:
    colossus/core/Worker.selectLoop()V @59: aload
  Reason:
    Type top (current frame, locals[7]) is not assignable to reference type
  Current Frame:
    bci: @59
    flags: { }
    locals: { 'colossus/core/Worker', integer, long, long_2nd, 'java/util/Set', 'java/util/Iterator', 'java/io/IOException', top, top, top, top, top, top, top, top, top, top, top, top, top, top, top, top, top, top, top, 'java/lang/Object', 'colossus/core/Connection' }
    stack: { 'colossus/core/Worker' }
  Bytecode:
    0x0000000: 2ab6 01f4 0ab6 0324 3c2a b603 262a b602
    0x0000010: 132a b603 26b9 032b 0100 b903 2e04 00b8
    0x0000020: 0333 412a b601 f4b6 0337 3a04 1904 b903
    0x0000030: 3d01 003a 05a7 0020 3a06 2a19 07bb 0030
    0x0000040: 5919 06b7 0340 b602 45b2 01bb 3a0a 1905
    0x0000050: b903 4301 0019 05b9 0346 0100 9902 f119
    0x0000060: 05b9 0349 0100 c001 fd3a 0819 08b6 034c
    0x0000070: 9902 ce19 08b6 034f 9900 2e19 08b6 0352
    0x0000080: c002 043a 0b19 0bb6 0236 a7ff c43a 0c2a
    0x0000090: 190b bb00 6b59 190c b702 41b6 0245 1908
    0x00000a0: b603 55a7 ffab 1908 b603 5899 01f7 2ab6
    0x00000b0: 035a b603 6057 1908 b603 64c0 01ea 3a0d
    0x00000c0: 190d 2ab6 035a b603 6836 0e15 0e02 a400
    0x00000d0: 4919 08b6 0352 3a0f 190f c102 ae99 0030
    0x00000e0: 190f c002 ae3a 102a b603 5ab6 036b 57b2
    0x00000f0: 0370 2ab6 035a 150e b603 733a 1119 1019
    0x0000100: 1120 b603 77b2 01bb 3a12 a701 98bb 01dd
    0x0000110: 5919 0fb7 01df bf19 08b6 0352 3a13 1913
    0x0000120: c102 ae99 0020 1913 c002 ae3a 142a 1914
    0x0000130: b203 7ab6 0245 1908 b603 55b2 01bb 3a15
    0x0000140: a701 62bb 01dd 5919 13b7 01df bf3a 162a
    0x0000150: b601 41bb 0143 59b2 0149 06bd 014b 5903
    0x0000160: 1303 7c53 5904 1302 3c53 5905 1301 4f53
    0x0000170: c001 51b6 0155 b701 59b2 0149 05bd 0004
    0x0000180: 5903 1916 b603 80b6 0385 5359 0419 16b6
    0x0000190: 0388 53b6 016b b601 6fb9 0317 0200 2ab6
    0x00001a0: 038a 9900 0819 16b6 038d 1908 b603 523a
    0x00001b0: 1719 17c1 02ae 9900 6219 17c0 02ae 3a18
    0x00001c0: 2ab6 0141 bb01 4359 b201 4905 bd01 4b59
    0x00001d0: 0313 038f 5359 0413 0391 53c0 0151 b601
    0x00001e0: 55b7 0159 b201 4904 bd00 0459 0319 18b6
    0x00001f0: 02af b802 0953 b601 6bb6 016f b903 1702
    0x0000200: 002a 1918 bb00 3059 1916 b703 40b6 0245
    0x0000210: b201 bb3a 19a7 0043 2ab6 0141 bb01 4359
    0x0000220: b201 4905 bd01 4b59 0313 0393 5359 0413
    0x0000230: 014f 53c0 0151 b601 55b7 0159 b201 4904
    0x0000240: bd00 0459 0319 1753 b601 6bb6 016f b901
    0x0000250: db02 00b2 01bb 3a19 190d b603 9519 08b6
    0x0000260: 0355 a700 403a 1a19 08b6 0352 3a1b 191b
    0x0000270: c102 ae99 0025 191b c002 ae3a 1c2a 191c
    0x0000280: b203 7ab6 0245 b201 bb3a 1d19 0db6 0395
    0x0000290: 1908 b603 55a7 000d bb01 dd59 191b b701
    0x00002a0: dfbf 1908 b603 4c99 fda7 1908 b603 9899
    0x00002b0: fd9f 1908 b603 523a 0919 09c1 02ae 9900
    0x00002c0: 7819 09c0 02ae 3a07 1907 2ab6 039a b603
    0x00002d0: 9e57 2ab6 039a b603 a3b2 01bb a7fd 703a
    0x00002e0: 1e2a b601 41bb 0143 59b2 0149 06bd 014b
    0x00002f0: 5903 1303 a553 5904 1303 a753 5905 1301
    0x0000300: 4f53 c001 51b6 0155 b701 59b2 0149 05bd
    0x0000310: 0004 5903 191e b603 80b6 0385 5359 0419
    0x0000320: 1eb6 0388 53b6 016b b601 6fb9 0317 0200
    0x0000330: b201 bba7 fd19 b201 bb3a 0aa7 fd13 2ab6
    0x0000340: 0141 1303 a9b9 01db 0200 a7fd 04b1
  Exception Handler Table:
    bci [712, 735] => handler: 56
    bci [712, 735] => handler: 735
    bci [192, 333] => handler: 613
    bci [192, 333] => handler: 333
    bci [133, 141] => handler: 141
  Stackmap Table:
    full_frame(@56,{Object[#2],Integer,Long,Object[#825],Object[#831],Object[#509],Top,Top,Top,Top,Top,Top,Top,Top,Top,Top,Top,Top,Top,Top,Top,Top,Top,Top,Top,Object[#4],Object[#686]},{Object[#798]})
    full_frame(@76,{Object[#2],Integer,Long,Object[#825],Object[#831],Top,Object[#686],Object[#509],Object[#4]},{Object[#439]})
    full_frame(@78,{Object[#2],Integer,Long,Object[#825],Object[#831],Top,Top,Object[#509]},{})
    chop_frame(@85,3)
    full_frame(@141,{Object[#2],Integer,Long,Object[#825],Object[#831],Top,Top,Object[#509],Top,Top,Object[#516]},{Object[#568]})
    chop_frame(@166,3)
    full_frame(@269,{Object[#2],Integer,Long,Object[#825],Object[#831],Top,Top,Object[#509],Top,Top,Top,Top,Object[#490],Integer,Object[#4]},{})
    chop_frame(@279,1)
    full_frame(@323,{Object[#2],Integer,Long,Object[#825],Object[#831],Top,Top,Object[#509],Top,Top,Top,Top,Object[#490],Integer,Top,Top,Top,Top,Object[#4]},{})
    full_frame(@333,{Object[#2],Integer,Long,Object[#825],Object[#831],Top,Top,Object[#509],Top,Top,Top,Top,Object[#490]},{Object[#568]})
    full_frame(@426,{Object[#2],Integer,Long,Object[#825],Object[#831],Top,Top,Object[#509],Top,Top,Top,Top,Object[#490],Top,Top,Top,Top,Top,Top,Top,Top,Object[#568]},{})
    append_frame(@536,Object[#4])
    append_frame(@600,Top,Object[#439])
    full_frame(@613,{Object[#2],Integer,Long,Object[#825],Object[#831],Top,Top,Object[#509],Top,Top,Top,Top,Object[#490]},{Object[#798]})
    full_frame(@664,{Object[#2],Integer,Long,Object[#825],Object[#831],Top,Top,Object[#509],Top,Top,Top,Top,Object[#490],Top,Top,Top,Top,Top,Top,Top,Top,Top,Top,Top,Top,Object[#798],Object[#4]},{})
    full_frame(@674,{Object[#2],Integer,Long,Object[#825],Object[#831],Top,Top,Object[#509]},{})
    full_frame(@735,{Object[#2],Integer,Long,Object[#825],Object[#831],Top,Object[#686],Object[#509],Object[#4]},{Object[#568]})
    full_frame(@822,{Object[#2],Integer,Long,Object[#825],Object[#831],Top,Top,Object[#509],Object[#4]},{})
    chop_frame(@830,1)
    chop_frame(@845,3)

    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
    at java.lang.Class.getDeclaredConstructors(Class.java:2020)
    at akka.util.Reflect$.findConstructor(Reflect.scala:90)
    at akka.actor.ArgsReflectConstructor.<init>(Props.scala:350)
    at akka.actor.IndirectActorProducer$.apply(Props.scala:309)
    at akka.actor.Props.producer(Props.scala:176)
    at akka.actor.Props.<init>(Props.scala:189)
    at akka.actor.Props$.apply(Props.scala:93)
    at colossus.core.DefaultWorkerFactory$.createWorker(WorkerManager.scala:231)
    at colossus.core.WorkerManager$$anonfun$2.apply(WorkerManager.scala:46)
    at colossus.core.WorkerManager$$anonfun$2.apply(WorkerManager.scala:46)
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
    at scala.collection.immutable.Range.foreach(Range.scala:160)
    at scala.collection.TraversableLike$class.map(TraversableLike.scala:234)
    at scala.collection.AbstractTraversable.map(Traversable.scala:104)
    at colossus.core.WorkerManager.<init>(WorkerManager.scala:46)
    ... 18 more

SBT:

import sbt._
import sbt.Keys._
import Keys._

name := """scala-spark-microservice"""

scalaVersion := "2.11.7"

exportJars := true

test in assembly := {}

mainClass in assembly := Some("edu.cmu.compbio.CMLHServer")

assemblyOption in assembly := (assemblyOption in assembly).value.copy(includeScala = false)

assemblyShadeRules in assembly := Seq(
  ShadeRule.rename("com.google.**" -> "shadeio.@1").inAll
)

resolvers += "Spark Packages Repo" at "https://dl.bintray.com/spark-packages/maven"

resolvers += "OSS Sonatype" at "https://repo1.maven.org/maven2/"

dependencyOverrides += "org.scala-lang" % "scala-compiler" % scalaVersion.value

libraryDependencies += "org.scalactic" % "scalactic_2.11" % "3.0.3"

libraryDependencies += "org.scalatest" % "scalatest_2.11" % "3.0.3" % "test"

libraryDependencies += "com.typesafe.akka" % "akka-actor_2.11" % "2.3.9"

libraryDependencies += "com.tumblr" % "colossus_2.11" % "0.9.0"

libraryDependencies += "com.datastax.spark" % "spark-cassandra-connector_2.11" % "2.0.3"

libraryDependencies += "org.json4s" % "json4s-native_2.11" % "3.5.3"

libraryDependencies += "org.json4s" % "json4s-jackson_2.11" % "3.5.3"

libraryDependencies += "org.apache.logging.log4j" % "log4j-core" % "2.8.2"

libraryDependencies += "org.apache.logging.log4j" % "log4j-api" % "2.8.2"

libraryDependencies += "org.apache.spark" % "spark-core_2.11" % "2.0.2" % "provided"

libraryDependencies += "org.apache.spark" % "spark-sql_2.11" % "2.1.0" % "provided"

libraryDependencies += "org.apache.spark" % "spark-mllib_2.11" % "2.1.0" % "provided"

Source:

import java.net.InetSocketAddress

import akka.util.ByteString
import akka.actor._

import colossus.IOSystem
import colossus.core.{ServerContext, ServerRef}
import colossus.protocols.http.HttpMethod._
import colossus.protocols.http.UrlParsing._
import colossus.protocols.http._
import colossus.protocols.http.server._
import colossus.protocols.redis._
import colossus.service.Callback.Implicits._
import colossus.service.Callback
import colossus.protocols.http.QueryParameters

import scala.concurrent.duration._

import UrlParsing._
import HttpMethod._

import org.apache.spark.sql.SparkSession
import org.apache.spark.SparkContext
import org.apache.spark.SparkConf
import org.apache.spark.sql.Row // for Row operations
import org.apache.spark.sql.SparkSession
import org.apache.spark.sql._ // for Row operations  
import org.apache.spark.sql.functions._ // to put feature columns into 1 column of feature arrays
import org.apache.spark.sql.types._ // import to cast DataType

import edu.cmu.compbio.model.{CMLHTaskList}

class CMLHColossusMicroService (HTTPPort:Int){

  class HttpExampleHandler(redis: RedisClient[Callback], 
                           context: ServerContext,
                           taskManager: CMLHTaskManager, 
                           aTaskList: CMLHTaskList, 
                           spark: SparkSession) extends RequestHandler(context){

    /**
    * colossus.protocols.http.QueryParameters
    */
    def printQueryString(query:QueryParameters): Unit = {

      var parameters : Seq[(String, String)] = query.parameters

      for ((k,v) <- parameters) {
        println ("Parameter: " + k + ", value: " + v)
      }

    }

    /**
    *
    */
    def invalidReply(reply: Reply) = s"Invalid reply from redis $reply"

    /**
    *
    */
    def handle = {

      case request @ Get on Root / "/api/v1/status" => {

        Callback.successful(request.ok("ok"))
      }
    }
  }

  /**
  *
  */
  def start(port: Int, 
            redisAddress: InetSocketAddress,
            taskManager: CMLHTaskManager, 
            aTaskList: CMLHTaskList, 
            spark: SparkSession)(implicit system: IOSystem): ServerRef = {

    HttpServer.start("http-example", port){init => new Initializer(init) {

      val redis: RedisClient[Callback] = Redis.client(redisAddress.getHostName, redisAddress.getPort, 1.second)

      def onConnect = context => new HttpExampleHandler(redis, context, taskManager, aTaskList, spark)
    }}
  }

  /**
  *
  */
  def runService (taskManager: CMLHTaskManager, 
                  aTaskList: CMLHTaskList, 
                  spark: SparkSession) : Unit = {
    println ("Starting microservice (Creating ActorSystem) ...")

    implicit val actorSystem = ActorSystem("COLOSSUS")

    println ("Starting microservice (Creating IOSystem) ...")

    implicit val ioSystem = IOSystem()

    println ("Starting microservice proper ...")

    start (HTTPPort,new InetSocketAddress("0.0.0.0", HTTPPort),taskManager,aTaskList,spark)
  }
}
benblack86 commented 7 years ago

Never seen that error before. Did you try sbt clean?