unfiltered/unfiltered — Issue #97: Scalate support throws an exception when testing plans in sbt with "~test"
Author: seanparsons
Created: 2011-11-14 13:01:08+00:00
State: open

When testing plans directly (mocked request and response objects) with the task as above I've found that the second time around these tests will fail with a NoClassDefFoundError for unfiltered.scalate.Scalate$. Knowing what usually causes these, I duplicated the class and made the private val's at the bottom of the definition lazy, which resulted in the following stack trace:
[info] Cause: java.lang.ClassCastException: org.fusesource.scalate.filter.ScalaMarkdownFilter$ cannot be cast to org.fusesource.scalate.TemplateEngineAddOn
[info] at org.fusesource.scalate.TemplateEngine$$anonfun$7.apply(TemplateEngine.scala:232)
[info] at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
[info] at scala.collection.immutable.List.foreach(List.scala:45)
[info] at org.fusesource.scalate.TemplateEngine.(TemplateEngine.scala:232)

This appears to be fixed by instead running "~;clean;test" which puzzles me somewhat and doesn't help me determine which part is actually causing the problem (there seems to be a side problem of SBT keeping that classloader alive or some such).

If nothing else, it would probably be helpful if those private val's in the Scalate object are made lazy as otherwise they will hide any underlying exceptions.