3

I am trying to upgrade Scala/Scalatra versions in our project to the following:

  • scala 2.10.1

  • scalatra (and scalatra-scalate, scalatra-scalatest) 2.2.0

using sbt 0.11.3

The code compiles OK but, when running the unit tests which uses scalatra TemplateEngine or when starting up our jetty server (also uses scalatra), I'm getting the error below.

Has anyone seen this? Any suggestions is very much appreciated.

Thanks!

java.lang.NoClassDefFoundError: scala/collection/GenTraversableLike$class at org.fusesource.scalate.TemplateEngine$$anon$1.(TemplateEngine.scala:162) at org.fusesource.scalate.TemplateEngine.sourceDirectoriesForwarder(TemplateEngine.scala:162) at org.fusesource.scalate.TemplateEngine.(TemplateEngine.scala:114) at com.springer.core.template.TemplateTestHelper$class.beforeAll(TemplateTestHelper.scala:19) at com.springer.core.template.SupportTemplateTest.beforeAll(SupportTemplateTest.scala:10) at org.scalatest.BeforeAndAfterAll$class.beforeAll(BeforeAndAfterAll.scala:150) at com.springer.core.template.SupportTemplateTest.beforeAll(SupportTemplateTest.scala:10)

Dreamwalker
  • 3,032
  • 4
  • 30
  • 60

2 Answers2

0

Without seeing your build.sbt or project/build.scala file it's hard to be sure, but here are a few things you might want to try.

First, I'm not aware of anybody yet trying Scalatra 2.2.0 with Scala 2.10.1, so you're in uncharted territory here. In theory, it should work, but a quick downgrade to 2.10.0 would rule it out.

Secondly, there were changes to the default wiring up of Scalate templates between 2.1.x and 2.2.0.

Scalatra 2.1.0 didn't include Scalate template compilation in the default g8 project skeleton, and this was a source of confusion for a lot of people who later wanted to deploy compiled templates in production. As a result, the default Scalatra 2.2.0 project skeleton comes with a few new features.

It wires up compiled templates, like this:

   /* wire up the precompiled templates */
  override protected def defaultTemplatePath: List[String] = List("/templates/views")

  override protected def createTemplateEngine(config: ConfigT) = {
    val engine = super.createTemplateEngine(config)
    engine.layoutStrategy = new DefaultLayoutStrategy(engine,
      TemplateEngine.templateTypes.map("/templates/layouts/default." + _): _*)
    engine.packagePrefix = "templates"
    engine
  }

It also adds a Scalate template compiler:

addSbtPlugin("com.mojolly.scalate" % "xsbt-scalate-generator" % "0.4.2")

If it's not a Scala 2.10.1-related problem, I'd recommend that the easiest way to determine whether it's the presentation compiler might be to look at (or generate and use) a new Scalatra 2.2.0 project skeleton using the latest g8.

futurechimp
  • 554
  • 4
  • 6
0

How are your dependencies defined in the build? Are they using %% instead of %
From 2.2.x and up we require the %% where before it was %
This could be the cause of the error you're seeing

Casual Jim
  • 1,179
  • 7
  • 13