ClassCastException when passing List of objects to Jade template

35 views
Skip to first unread message

4e6

unread,
Apr 14, 2012, 3:48:50 AM4/14/12
to sca...@googlegroups.com
For example, I have a class
case class Person(name: String)

And when I pass a list of persons to some template
engine.layout("views/results.jade", Map("results" -> List(Person("foo"), Person("bar"))))

I get [ClassCastException: models.Person cannot be cast to models.Person]. However, simpler lists, for example List[String] are passed well.
P.S. using Scala 2.9.1; Scalate 1.5.3

4e6

unread,
Apr 14, 2012, 1:24:00 PM4/14/12
to sca...@googlegroups.com
I managed to solve the problem by myself. Turned out, I didn't configure TemplateEngine's classLoader properly.

virtualeyes

unread,
Apr 15, 2012, 7:24:42 AM4/15/12
to Scalate
In your layout or view, what does your "@ val people: ..." look like?

I would assume that something like
@ val people: List[models.Person]

would be enough information for Scalate to be able to work with people
Reply all
Reply to author
Forward
0 new messages