AbstractMethodError when invoking method not in interface for TypedActor
Hello, as shown in the following code + test I am running into a problem when trying to call a method on a TypedActor if the actor's method is not implemented in the implementation class or the trait which is used when calling TypedActor.newInstance (but in a base trait) - I get a java.lang.AbstractMethodError The first two TestMethods succeed, the others fail (to say I get the expected exception) I don't know if this is caused by the proxying/weaving for TypedActors or if I am doing smthg wrong? (I am using akka 1.0-M1, sorry for posting all the code, but this way you can easily reproduce...) thanx in advance for any help, michael *************************** Implementation ****************************** package com.mh import se.scalablesolutions.akka.actor.TypedActor /** * Created by IntelliJ IDEA. * User: delasoul * Date: 22.11.10 * Time: 21:19 * To change this template use File | Settings | File Templates. */ trait Base { val id: String def getSomething(key: String): String = id + key } trait MyBaseOne extends Base { val id: String = "myBaseOne " def getSomethingDifferent(key: Int): Int } trait MyBaseTwo extends Base { val id: String = "myBaseTwo " } class MyBaseOneImpl extends TypedActor with MyBaseOne { override def getSomethingDifferent(key: Int): Int = key + 2 } class MyBaseTwoImpl extends TypedActor with MyBaseTwo ******************************* Test *********************************** package com.mh import org.specs.Specification import se.scalablesolutions.akka.actor.TypedActor /** * Created by IntelliJ IDEA. * User: delasoul * Date: 22.11.10 * Time: 21:40 * To change this template use File | Settings | File Templates. */ class TypedActorsTest extends Specification { "TypedActor" should { "return int" in { val myBaseOneActor: MyBaseOne = TypedActor.newInstance[MyBaseOne](classOf[MyBaseOne], classOf[MyBaseOneImpl], 3000) try { myBaseOneActor.getSomethingDifferent(5) mustEqual 7 } catch { case e: Exception => println(e.toString) } finally { TypedActor.stop(myBaseOneActor) } } "return string" in { val myBaseOneActor: Base = TypedActor.newInstance[Base](classOf[Base], classOf[MyBaseOneImpl], 3000) try { myBaseOneActor.getSomething("hello") mustEqual "myBaseOne hello" } catch { case e: Exception => println(e.toString) } finally { TypedActor.stop(myBaseOneActor) } } "fail for myBaseTwo" in { val myBaseTwoActor: MyBaseTwo = TypedActor.newInstance[MyBaseTwo](classOf[MyBaseTwo], classOf[MyBaseTwoImpl], 3000) try { myBaseTwoActor.getSomething("hello") must throwA[java.lang.AbstractMethodError] } catch { case e: Exception => println(e.toString) } finally { TypedActor.stop(myBaseTwoActor) } } "fail for myBaseOne inherited method" in { val myBaseOneActor: MyBaseOne = TypedActor.newInstance[MyBaseOne](classOf[MyBaseOne], classOf[MyBaseOneImpl], 3000) try { myBaseOneActor.getSomething("hello") must throwA[java.lang.AbstractMethodError] } catch { case e: Exception => println(e.toString) } finally { TypedActor.stop(myBaseOneActor) } } } } ************************************** sbt ************************************************ import sbt._ class TypedActorTestProject(info: ProjectInfo) extends DefaultProject(info) { // ------------------------------------------------------------------------------------------------------------------- // Versions // ------------------------------------------------------------------------------------------------------------------- lazy val AKKA_VERSION = "1.0-M1" object Repositories { lazy val AkkaRepo = MavenRepository("Akka Repository", "http://scalablesolutions.se/akka/repository ") lazy val CodehausSnapshotRepo = MavenRepository("Codehaus Snapshots", "http://snapshots.repository.codehaus.org ") lazy val CodehausRepo = MavenRepository("Codehaus Repo", "http://repository.codehaus.org ") lazy val GuiceyFruitRepo = MavenRepository("GuiceyFruit Repo", "http://guiceyfruit.googlecode.com/svn/repo/releases/ ") lazy val JBossRepo = MavenRepository("JBoss Repo", "http://repository.jboss.org/nexus/content/groups/public/ ") lazy val JavaNetRepo = MavenRepository("java.net Repo", "http://download.java.net/maven/2 ") lazy val SonatypeSnapshotRepo = MavenRepository("Sonatype OSS Repo", "http://oss.sonatype.org/content/repositories/releases ") lazy val SunJDMKRepo = MavenRepository("Sun JDMK Repo", "http://wp5.e-taxonomy.eu/cdmlib/mavenrepo ") } import Repositories._ lazy val atmosphereModuleConfig = ModuleConfiguration("org.atmosphere", SonatypeSnapshotRepo) lazy val grizzlyModuleConfig = ModuleConfiguration("com.sun.grizzly", JavaNetRepo) lazy val guiceyFruitModuleConfig = ModuleConfiguration("org.guiceyfruit", GuiceyFruitRepo) lazy val jbossModuleConfig = ModuleConfiguration("org.jboss", JBossRepo) lazy val jdmkModuleConfig = ModuleConfiguration("com.sun.jdmk", SunJDMKRepo) lazy val jerseyContrModuleConfig = ModuleConfiguration("com.sun.jersey.contribs", JavaNetRepo) lazy val jerseyModuleConfig = ModuleConfiguration("com.sun.jersey", JavaNetRepo) lazy val jgroupsModuleConfig = ModuleConfiguration("jgroups", JBossRepo) lazy val jmsModuleConfig = ModuleConfiguration("javax.jms", SunJDMKRepo) lazy val jmxModuleConfig = ModuleConfiguration("com.sun.jmx", SunJDMKRepo) lazy val liftModuleConfig = ModuleConfiguration("net.liftweb", ScalaToolsSnapshots) lazy val multiverseModuleConfig = ModuleConfiguration("org.multiverse", CodehausRepo) lazy val nettyModuleConfig = ModuleConfiguration("org.jboss.netty", JBossRepo) lazy val scalaTestModuleConfig = ModuleConfiguration("org.scalatest", ScalaToolsSnapshots) lazy val akkaModuleConfig = ModuleConfiguration("se.scalablesolutions.akka", AkkaRepo) lazy val compressModuleConfig = ModuleConfiguration("voldemort.store.compress", AkkaRepo) lazy val sjsonModuleConfig = ModuleConfiguration("sjson.json", AkkaRepo) lazy val jsr166xModuleConfig = ModuleConfiguration("jsr166x", AkkaRepo) lazy val sbinaryModuleConfig = ModuleConfiguration("sbinary", AkkaRepo) lazy val allOthers = AkkaRepo object Dependencies { // ------------------------------------------------------------------------------------------------------------------- // compile // ------------------------------------------------------------------------------------------------------------------- lazy val akkaActor = "se.scalablesolutions.akka" % "akka- actor_2.8.0" % AKKA_VERSION % "compile" withSources() lazy val akkaTypedActor = "se.scalablesolutions.akka" % "akka- typed-actor_2.8.0" % AKKA_VERSION % "compile" withSources() lazy val akkaHttp = "se.scalablesolutions.akka" % "akka- http_2.8.0" % AKKA_VERSION % "compile" withSources() // ------------------------------------------------------------------------------------------------------------------- // test // ------------------------------------------------------------------------------------------------------------------- lazy val junit = "junit" % "junit" % "4.5" % "test" withSources() lazy val specs = "org.scala-tools.testing" %% "specs" % "1.6.5" % "test" withSources() } // Dependencies /* compile */ val akkaActor = Dependencies.akkaActor val akkaTypedActor = Dependencies.akkaTypedActor val akkaHttp = Dependencies.akkaHttp /* test */ val junit = Dependencies.junit val specs = Dependencies.specs }
Leave a comment
Does it work if you only declare unimplemented defs?
If so, then working as designed, if not, reopen the ticket.
Thanks!
If so, then working as designed, if not, reopen the ticket.
Thanks!