The Artima Developer Community
Sponsored Link

Akka Concurrency Forum
java.lang.NoSuchMethodError running Chapter 6 test

2 replies on 1 page. Most recent reply: Nov 28, 2012 6:57 AM by Andreas Gies

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Andreas Gies

Posts: 15
Nickname: 84653
Registered: Nov, 2012

java.lang.NoSuchMethodError running Chapter 6 test Posted: Nov 28, 2012 6:27 AM
Reply to this message Reply
Advertisement
Hi,

I am a step further in compiling my tests, but now running it yields in another error:

----------------------------------------------------------------------- --------
Test set: zzz.akka.avionics.EventSourceSpec
--------------------------------------------- ----------------------------------
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.001 sec <<< FAILURE!
initializationError(zzz.akka.avionics.EventSourceSpec) Time elapsed: 0.007 sec <<< ERROR!
java.lang.NoSuchMethodError: scala.Predef$ArrowAssoc$.extension$$minus$greater(Ljava/lang/Object;Ljava/lang/ Object;)Lscala/Tuple2;
at org.scalatest.SuperEngine.registerTest(Engine.scala:463)
at org.scalatest.WordSpec$class.org$scalatest$WordSpec$$registerTestToRun(WordSpec .scala:1646)
at org.scalatest.WordSpec$WordSpecStringWrapper.in(WordSpec.scala:1783)
at zzz.akka.avionics.EventSourceSpec$$anonfun$1.apply$mcV$sp(EventSourceSpec.scala :22)
at zzz.akka.avionics.EventSourceSpec$$anonfun$1.apply(EventSourceSpec.scala:22)
at zzz.akka.avionics.EventSourceSpec$$anonfun$1.apply(EventSourceSpec.scala:22)
at org.scalatest.SuperEngine.registerNestedBranch(Engine.scala:411)
at org.scalatest.WordSpec$class.org$scalatest$WordSpec$$registerBranch(WordSpec.sc ala:1673)
at org.scalatest.WordSpec$$anon$1.apply(WordSpec.scala:2113)
at org.scalatest.verb.ShouldVerb$StringShouldWrapperForVerb.should(ShouldVerb.scal a:189)

...

Google suggests that I still have Scala 2.9.x dependencies in my classpath, but I am fairly sure I haven't.



I have configured a JUnitRunner to execute my test with Surefire (as I have done in other, non-Akka related Scala projects)

package zzz.akka.avionics

import akka.actor.{ActorSystem}
import akka.testkit.{TestActorRef, TestKit, ImplicitSender}
import org.scalatest.{BeforeAndAfterAll, WordSpec}
import org.scalatest.matchers.MustMatchers
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner

@RunWith(classOf[JUnitRunner])
class EventSourceSpec extends TestKit(ActorSystem("EventSourceSpec"))
with WordSpec
with MustMatchers
with BeforeAndAfterAll {

import EventSource._

override protected def afterAll() { system.shutdown() }

"EventSource" should {

"allow us to register a listener" in {
val real = TestActorRef[MyEventSource].underlyingActor
real.receive(RegisterListener(testActor))
real.listeners must contain (testActor)
}

}


For completeness, this is my current classpath reported from Maven:

[INFO] The following files have been resolved:
[INFO] com.typesafe:config:jar:1.0.0:compile
[INFO] com.typesafe.akka:akka-actor_2.10.0-RC2:jar:2.1.0-RC2:compile
[INFO] com.typesafe.akka:akka-testkit_2.10.0-RC2:jar:2.2-SNAPSHOT:test
[INFO] junit:junit:jar:4.9:compile
[INFO] org.hamcrest:hamcrest-core:jar:1.1:compile
[INFO] org.scala-lang:scala-actors:jar:2.10.0-RC2:compile
[INFO] org.scala-lang:scala-actors-migration_2.10.0-RC2:jar:1.0.0-RC2:compile
[INFO] org.scala-lang:scala-library:jar:2.10.0-RC2:compile
[INFO] org.scala-lang:scala-library-all:pom:2.10.0-RC2:compile
[INFO] org.scala-lang:scala-reflect:jar:2.10.0-RC2:compile
[INFO] org.scala-lang:scala-swing:jar:2.10.0-RC2:compile
[INFO] org.scalatest:scalatest_2.10.0-M4:jar:1.9-2.10.0-M4-B1:test

Perhaps you have seen this in the past...


Great book btw.
Andreas


Derek Wyatt

Posts: 69
Nickname: dwyatt
Registered: Oct, 2012

Re: java.lang.NoSuchMethodError running Chapter 6 test Posted: Nov 28, 2012 6:33 AM
Reply to this message Reply
That's a new one on me. But... I've never done Maven and ScalaTest before. I'm not sure if it has anything to do with it but you might have better luck asking on the ScalaTest forum: https://groups.google.com/forum/?fromgroups#!forum/scalatest-users

It does look like there's some interesting classpath stuff going on, and I don't think you've actually pasted the classpath. As far as I recall, the best way to get it is "mvn dependency:build-classpath".

Andreas Gies

Posts: 15
Nickname: 84653
Registered: Nov, 2012

Re: java.lang.NoSuchMethodError running Chapter 6 test Posted: Nov 28, 2012 6:57 AM
Reply to this message Reply
You are right, I didn't paste the classpath, but the output from the dependency:build-classpath ;)

However,

Changing the test to

@RunWith(classOf[JUnit4])
class EventSourceSpec extends TestKit(ActorSystem("EventSourceSpec"))
with WordSpec
with MustMatchers
with BeforeAndAfterAll {

import EventSource._

override protected def afterAll() { system.shutdown() }

"EventSource" should {

"allow us to register a listener" in {
val actor = TestActorRef[MyEventSource](Props[MyEventSource])
val real = actor.underlyingActor
real.receive(RegisterListener(testActor))
real.listeners must contain (testActor)
}

}
}

works fine.

Thanks for the quick responses
Andreas

Flat View: This topic has 2 replies on 1 page
Topic: Ch 7: AutoPilot missing in text and code Previous Topic   Next Topic Topic: Bad symbolic reference to class Duration in package util

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use