The Artima Developer Community
Sponsored Link

Akka Concurrency Forum
Bad symbolic reference to class Duration in package util

3 replies on 1 page. Most recent reply: Nov 28, 2012 8:05 AM by Derek Wyatt

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 3 replies on 1 page
Andreas Gies

Posts: 15
Nickname: 84653
Registered: Nov, 2012

Bad symbolic reference to class Duration in package util Posted: Nov 28, 2012 6:24 AM
Reply to this message Reply
Advertisement
Hi again,

I am just going through the testing chapter. I have come around the issues of refactoring by switching to Scala 2.10 RC2.

The error I am getting is
bad symbolic reference to class Duration in package util (a classfile may be missing)

after creating the EventSourceSpec on page 129/130. I have spent some time googling, but I seem to be unable to nail down the issue. My feeling is, that the Akka-Actor version coming with 2.10 RC2 and the testkit do not play well together, but I can't proof that for now.

Also, the scalatest version on page 127 could not be resolved in any repository i looked at. The version that I did find was

<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.10.0-M4</artifactId>
<version>1.9-2.10.0-M4-B1</version>
<scope>test</scope>
</dependency>

The classpath for running the example is now:

[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:jar:2.1-M1: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 error before, perhaps it is just a missing jar as the error message suggests, but I can't spot, which.


Thanks and best regards
Andreas


Andreas Gies

Posts: 15
Nickname: 84653
Registered: Nov, 2012

Re: Bad symbolic reference to class Duration in package util Posted: Nov 28, 2012 7:15 AM
Reply to this message Reply
Hello,

I have done a bit of search and got around the compile error by using the following version of akka-testkit:

<groupId>com.typesafe.akka</groupId>
<artifactId>akka-testkit_2.10.0-RC2</artifactId>
<version>2.2-SNAPSHOT</version>
<scope>test</scope>

This lives in the typesafe maven repo at http://repo.akka.io/snapshots.

Though the compile works, the sample code runs into an exception:

Caused by: cb1bf64f-7bb1-4049-b7f2-54411b4e45f0akka.actor.ActorInitializationException:
You cannot create an instance of [zzz.akka.avionics.TestEventSource] explicitly using the constructor (new).
You have to use one of the factory methods to create a new actor. Either use:
'val actor = context.actorOf(Props[MyActor])' (to create a supervised child actor from within an actor), or
'val actor = system.actorOf(Props(new MyActor(..)))' (to create a top level actor from the ActorSystem)

For completeness, this is my current Spec class:

package zzz.akka.avionics

import akka.actor.{ActorSystem, Actor}
import akka.testkit.{TestActorRef, TestKit, ImplicitSender}
import org.scalatest.{BeforeAndAfterAll, WordSpec}
import org.scalatest.matchers.MustMatchers

class TestEventSource extends Actor with ProductionEventSource {
def receive = eventSourceReceive
}

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[TestEventSource].underlyingActor
real.receive(RegisterListener(testActor))
real.listeners must contain (testActor)
}

}

}

I am not sure, where I made the mistake, but it's probably me trying to pick up Scala & Akka at the same time not spotting the obvious.

Best regards
Andreas

Andreas Gies

Posts: 15
Nickname: 84653
Registered: Nov, 2012

Re: Bad symbolic reference to class Duration in package util Posted: Nov 28, 2012 7:40 AM
Reply to this message Reply
Hello again,

rereading the error message, someone tried to instantiate TestEventSource. In that particular case I tricked myself by using maven. The surefire plugin, tried to instantiate the class because it starts with "Test" and that failed.

In my environment, renaming "TestEventSource" to "MyEventSource" (couldn't come up with a better name for now) did the trick.

In summary, the root cause of my problem seemed to be a wrong version of the testkit. For convenience here is the complete dependency list that works for me:

[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] 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

Best regards
Andreas

Derek Wyatt

Posts: 64
Nickname: dwyatt
Registered: Oct, 2012

Re: Bad symbolic reference to class Duration in package util Posted: Nov 28, 2012 8:05 AM
Reply to this message Reply
Glad to hear it :)

Just be aware that the book was written using Scala 2.10.0-M6 and a snapshot build of Akka 2.1, in order to get the latest I could at the time.

As these packages move forward, the book will get increasingly out of date. Once Scala and Akka officially release, I'll be able to bring to book up to spec with those releases.

Flat View: This topic has 3 replies on 1 page
Topic: java.lang.NoSuchMethodError running Chapter 6 test Previous Topic   Next Topic Topic: Chapter 8 Page 198 actorOf in startControls()


Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2014 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us