1

I try to instantiate an ActorSystem like below

import akka.actor.{ActorRef, ActorSystem, Props}

object Main {
  def main(args: Array[String])  {

    val system: ActorSystem = ActorSystem("MySystem")
  }
}

the dependencies in my pom.xml is like this:

<dependencies>
    <dependency>
        <groupId>com.typesafe.akka</groupId>
        <artifactId>akka-actor_2.11</artifactId>
        <version>2.5.0</version>
    </dependency>
    <dependency>
        <groupId>net.alchim31.maven</groupId>
        <artifactId>scala-archetype-simple</artifactId>
        <version>1.6</version>
    </dependency>
    <dependency>
        <groupId>org.scala-lang</groupId>
        <artifactId>scala-library</artifactId>
        <version>2.11.1</version>
    </dependency>
</dependencies>

I think I have conflict in version of Scala and Akka. I have tried multiple combination but I always get this exception:

Exception in thread "main" java.lang.NoSuchMethodError:

scala.Predef$.ArrowAssoc(Ljava/lang/Object;)Ljava/lang/Object;
    at akka.actor.setup.ActorSystemSetup$$anonfun$apply$1.apply(ActorSystemSetup.scala:36)
    at akka.actor.setup.ActorSystemSetup$$anonfun$apply$1.apply(ActorSystemSetup.scala:36)
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
    at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)
    at scala.collection.mutable.WrappedArray.foreach(WrappedArray.scala:34)
    at scala.collection.TraversableLike$class.map(TraversableLike.scala:244)
    at scala.collection.AbstractTraversable.map(Traversable.scala:105)
    at akka.actor.setup.ActorSystemSetup$.apply(ActorSystemSetup.scala:36)
    at akka.actor.ActorSystem$.apply(ActorSystem.scala:287)
    at akka.actor.ActorSystem$.apply(ActorSystem.scala:232)
    at Main$.main(Main.scala:9)
    at Main.main(Main.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

Do you have any idea?

a.moussa
  • 2,977
  • 7
  • 34
  • 56
  • Possible duplicate of [No option to reimport dependencies in Maven (IntelliJ)](https://stackoverflow.com/questions/39197849/no-option-to-reimport-dependencies-in-maven-intellij) – Gábor Bakos Dec 22 '17 at 20:47

2 Answers2

0

I use Intellij IDE and in File -> project structure, there is a section called Global library where scala sdk 2.10 was affected. switch to 2.11 correct the issue

a.moussa
  • 2,977
  • 7
  • 34
  • 56
  • 1
    I have checked and there seems to be a Maven/Reimport option in the module's context menu. If you make manual changes in the global libraries, things will break again soon. – Gábor Bakos Dec 22 '17 at 20:46
-1

Sure, you should use the Akka version corresponding to your Scala version, 2.12:

<dependency>
    <groupId>com.typesafe.akka</groupId>
    <artifactId>akka-actor_2.12</artifactId>
    <version>2.5.0</version>
</dependency>

Scala 2.11 and Scala 2.12 versions are not binary compatible.

Gábor Bakos
  • 8,982
  • 52
  • 35
  • 52
  • Hi thank you for the answer. I replace Scala version to 2.11.1 but I get the same error. I will edit my post with your comment. – a.moussa Dec 22 '17 at 20:04
  • Are you using an IDE? Have you updated the configuration after the change? (I think that is necessary in Eclipse's m2e, not sure about others.) (BTW: if you do not want to use Scala 2.12(.4), you should use 2.11.12, not 2.11.1.) – Gábor Bakos Dec 22 '17 at 20:09
  • I use Intellij but what do you mean by update my configuration? – a.moussa Dec 22 '17 at 20:13
  • In eclipse we have to use a context menu to notify eclipse about the changes in the configuration and apply those to the project. I expect in case in intelliJ this is required, a message should appear somewhere when you open the pom.xml file with a button to do the changes. (Sorry, I have never used IDEA with maven.) – Gábor Bakos Dec 22 '17 at 20:16
  • I have delete my .m2 repository and import again my dependencies but It does not change anything. This is strange since intellij don't bug at compilation. – a.moussa Dec 22 '17 at 20:20