0

I am trying to create a new Scala project with Spray and Akka. I am using Scala 2.12.1 and my pom looks like this.

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

    <dependency>
        <groupId>org.scala-lang</groupId>
        <artifactId>scala-library</artifactId>
        <version>2.12.1</version>
    </dependency>

    <dependency>
        <groupId>com.enragedginger</groupId>
        <artifactId>akka-quartz-scheduler_2.12</artifactId>
        <version>1.6.0-akka-2.4.x</version>
    </dependency>

    <dependency>
        <groupId>io.spray</groupId>
        <artifactId>spray-servlet</artifactId>
        <version>1.3.1</version>
    </dependency>

    <dependency>
        <groupId>io.spray</groupId>
        <artifactId>spray-routing</artifactId>
        <version>1.3.1</version>
    </dependency>

    <dependency>
        <groupId>com.typesafe.akka</groupId>
        <artifactId>akka-slf4j_2.12</artifactId>
        <version>2.4.16</version>
    </dependency>

    <dependency>
        <groupId>com.typesafe.akka</groupId>
        <artifactId>akka-http-spray-json_2.12</artifactId>
        <version>10.0.5</version>
    </dependency>

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.6</version>
    </dependency>

    <dependency>
        <groupId>commons-dbutils</groupId>
        <artifactId>commons-dbutils</artifactId>
        <version>1.6</version>
    </dependency>


    <dependency>
        <groupId>joda-time</groupId>
        <artifactId>joda-time</artifactId>
        <version>2.9.9</version>
    </dependency>

    <dependency>
        <groupId>org.scala-lang.modules</groupId>
        <artifactId>scala-xml_2.12</artifactId>
        <version>1.0.6</version>
    </dependency>

</dependencies>

This pom builds a WAR file, but each time I try to deploy that WAR file onto a server I get the following error. I believe the dependencies I am using are compatible with Scala 2.12.1, can you all spot what's wrong?

java.lang.NoClassDefFoundError: scala/Product$class
    at spray.http.Uri$Path$Empty$.<init>(Uri.scala:435)
    at spray.http.Uri$Path$Empty$.<clinit>(Uri.scala)
    at spray.http.Uri$Path$.<init>(Uri.scala:415)
    at spray.http.Uri$Path$.<clinit>(Uri.scala)
    at spray.servlet.ConnectorSettings$.fromSubConfig(ConnectorSettings.scala:52)
anonymous123
  • 1,271
  • 6
  • 19
  • 43
  • are you building a WAR with all the dependencies included. I never used WAR on the JVM, I've always used fat jat: http://stackoverflow.com/questions/23089700/deploy-war-or-fat-jar – pedrorijo91 Apr 14 '17 at 19:38
  • Yep, war with all the dependencies. But I am deploying that war through intellij. – anonymous123 Apr 14 '17 at 20:26
  • as suggestion, you should consider to use akka-http which is compatible with scala 2.12.1 and supersedes spray –  Apr 14 '17 at 20:29

1 Answers1

1

I don't think spray-* jars have crossPath builds for scala 2.12. Use Akka-Http 10.0.x for 2.12, its code is pretty much API compatible with spray-framework.

Also note that using WARs/servlets whose async capabilities are rather limited kind of goes against the whole idea behind Akka.

Please also use typesafe akka* jars of version 2.4.17 together with typesafe akka-http* 10.0.5 in order to ensure version compatibility.

Sheinbergon
  • 2,875
  • 1
  • 15
  • 26