Antoine
Antoine

Reputation: 1812

ClassNotFoundException: spray.json.JsonFormat

I'm trying to use spray-json.

The following test code throws ClassNotFoundException: spray.json.JsonFormat:

import spray.json._
import DefaultJsonProtocol._

object App {
  def main(args: Array[String]) = {
    val ast = List(1, 2, 3).toJson
    println(ast.compactPrint)
  }
}

Can anyone tell me why?

Upvotes: 0

Views: 1097

Answers (2)

Antoine
Antoine

Reputation: 1812

I was using sbt's package command for generating the final jar file. It apparently doesn't package the dependencies altogether.

I fixed this by using the sbt-assembly plugin.

Upvotes: 3

perbellinio
perbellinio

Reputation: 682

The error means that the class spray.json.JsonFormat is not found at run time.

Make sure this class is part of your run time dependencies.

Upvotes: 0

Related Questions