Re: [scala-ide-user] Akka ActorSystem errors with Scala IDE

143 views
Skip to first unread message

Roland Kuhn

unread,
May 4, 2013, 3:47:02 PM5/4/13
to scala-i...@googlegroups.com
Hi Jamie,

the symptom you describe is usually caused by a mismatch between the package your TryThis class is in and the file system directory where the corresponding source is located. This is a restriction in Eclipse which ultimately originates from the Java class file format. Why this would happen only when calling methods on the ActorSystem companion object is beyond me, though.

Regards,

Roland

4 maj 2013 kl. 20:27 skrev Jamie Lawson:

I am experiencing a very odd interaction between the Akka ActorSystem class and Scala IDE for Eclipse. Any fixes or work arounds would be most welcomed.

PROBLEM DESCRIPTION:
Any use of akka.actor.ActorSystem (over and above a mere import statement) causes a failure of Eclipse to find the class file for my program. The program seems to compile fine, but then Scala IDE gets confused. I don't even have to use ActorSystem instances or companion object methods. Even something as trivial as getting its classname causes the problem. Here are two very short programs that illustrate the error. The first program works (uses Actor rather than ActorSystem), the second program doesn't work. The only difference between the programs is the change from Actor to ActorSystem. I've used import statements in the examples to show that you can import ActorSystem without problem but the same behavior occurs when you remove the imports and use fully qualified class names instead. Other classes in the same package do not seem to lead to the problem. Only ActorSystem. Details of my environment are at the end of this post:

=======================
Program #1: Use Actor class
---------------------------------------------
    import akka.actor.{Actor, ActorSystem}
    object TryThis {
      def main(args: Array[String]) = println(Actor.getClass)
    }

Result:
Program compiles and runs fine.
Prints the string "class akka.actor.Actor$"

=============================
Program #2: Use ActorSystem class
----------------------------------------------------------
    import akka.actor.{Actor, ActorSystem}
    object TryThis {
      def main(args: Array[String]) = println(ActorSystem.getClass)
    }

Result:
Program compiles and builds fine, but when it is run, an Eclipse dialog pops up and says "Errors in workspace--Errors exist in required project(s)". 
The output (Console) window in Eclipse says, in red: "Error: Could not find or load main class TryThis"
There are no indications in Eclipse (no red X's or anything similar) to indicate a problem or suggest a remedy. The failure does not appear to come while executing the program. It appears that the Eclipse runtime cannot find the program's class, even though it compiles successfully.
=============================

These results are consistent. I've 
  1. Re-installed everything but the operating system, 
  2. Tried many different variations of the second program. 
    1. I started out with val system = ActorSystem("MySystem") instead of println(ActorSystem.getClass)
    2. I have redone the programs using fully qualified class names instead of import statements
  3. Used earlier versions of Akka with Scala 2.9 without these problems. 
  4. Used ActorSystem from the Scala REPL (in my current environment) without issue.
  5. Tried this using both Eclipse Juno and Eclipse Indigo and the same thing happens. 
  6. Not seen the problem with anything except ActorSystem.

==================
Environment:
-----------------------------------
OS: Linux Kubuntu 12.04
Eclipse version: Juno (same thing happens with Indigo though)
Scala IDE version: 3.0.0
Java version: 1.7.0_17
Scala version: 2.10.1
Akka version: 2.1.2
Eclipse project build path: contains akka-actor_2.10-2.1.2.jar in addition to the JRE and Scala 2.10.1 

Thanks,
Jamie Lawson


--
You received this message because you are subscribed to the Google Groups "Scala IDE User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-ide-use...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



Dr. Roland Kuhn
Akka Tech Lead
Typesafe – Empowering professional developers to build amazing apps.
twitter: @rolandkuhn

See you at Scala Days 2013 in NYC!
June 10th - June 12th
www.scaladays.org

Reply all
Reply to author
Forward
0 new messages