Installing Scalate into Play

274 views
Skip to first unread message

Matt Raible

unread,
Aug 24, 2011, 12:22:59 AM8/24/11
to Scalate
Hello all,

I'm trying to integrate Scalate into Play and running into some
issues. I'm using the instructions at:

http://www.playframework.org/modules/scalate-0.7.2/home

In dependencies.yml, I have:

require:
- play
- play -> scala 0.9.1
- play -> scalate 0.7.2

application.conf has:

scalate=ssp

jvm.memory=-Xmx256M

When I try to run the app (after creating views/Application/
index.ssp), I get the following error:

22:13:16,400 WARN ~ Cannot introspect on class loader: (play) [class
DocViewerPlugin, class controllers.Application, class
controllers.Application$, class controllers.PlayDocumentation, class
helpers.CheatSheetHelper, class helpers.CheatSheetHelper$1, class
helpers.CheatSheetHelper$2, class helpers.CheatSheetHelper$3] of type
play.classloading.ApplicationClassloader
22:13:17,564 ERROR ~ Compilation failed:
/Users/mraible/dev/play-more/tmp/src/errors/500.scaml.scala:5: error:
not found: value models
import controllers._;import models._;import play.utils._
^
My project doesn't have a "models" package, so I created one and
dropped a "User" object into it.

From app/models/User.scala:

package models

class User

This gets me a little further, but not much. Now I see the following
page in my browser (in raw HTML):

<link href="/public/stylesheets/500.css" rel="stylesheet" type="text/
css"/>
<div id="scalate-error">
<div class="header block">
<h1>
Template file extension missing. Cannot determine which template
processor to use.
</h1>
<p>
org.fusesource.scalate.TemplateException: Template file extension
missing. Cannot determine which template processor to use.
</p>
</div>
<div class="details block">
<pre class="stacktrace">at
org.fusesource.scalate.TemplateEngine.generator(TemplateEngine.scala:
657)</pre>
<pre class="stacktrace">at
org.fusesource.scalate.TemplateEngine.compileAndLoad(TemplateEngine.scala:
557)</pre>
<pre class="stacktrace">at
org.fusesource.scalate.TemplateEngine.compileAndLoadEntry(TemplateEngine.scala:
523)</pre>
<pre class="stacktrace">at
org.fusesource.scalate.TemplateEngine.liftedTree1$1(TemplateEngine.scala:
255)</pre>
<pre class="stacktrace">at
org.fusesource.scalate.TemplateEngine.load(TemplateEngine.scala:249)</
pre>
<pre class="stacktrace">at
org.fusesource.scalate.TemplateEngine.load(TemplateEngine.scala:307)</
pre>
<pre class="stacktrace">at
org.fusesource.scalate.TemplateEngine.layout(TemplateEngine.scala:
381)</pre>
<pre class="stacktrace">at
org.fusesource.scalate.TemplateEngine.layout(TemplateEngine.scala:
427)</pre>
<pre class="stacktrace">at play.mvc.scalate.Provider
$class.renderScalateTemplate(Provider.scala:101)</pre>
<pre class="stacktrace">at play.mvc.scalate.Provider
$class.renderWithScalate(Provider.scala:29)</pre>
<pre class="stacktrace">at
play.mvc.ScalateController.renderWithScalate(ScalateController.scala:
3)</pre>
<pre class="stacktrace">at
play.mvc.ScalateController.render(ScalateController.scala:4)</pre>
<pre class="stacktrace">at controllers.Application$.index(app/
controllers/Application.scala:7)</pre>
<pre class="stacktrace">at
sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java:-2)</
pre>
<pre class="stacktrace">at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)</pre>
<pre class="stacktrace">at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)</pre>
<pre class="stacktrace">at
java.lang.reflect.Method.invoke(Method.java:597)</pre>
<pre class="stacktrace">at
play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:540)</
pre>
<pre class="stacktrace">at
play.mvc.ActionInvoker.invoke(ActionInvoker.java:498)</pre>
<pre class="stacktrace">at
play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:492)</
pre>
<pre class="stacktrace">at
play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:469)</
pre>
<pre class="stacktrace">at
play.mvc.ActionInvoker.invoke(ActionInvoker.java:157)</pre>
<pre class="stacktrace">at play.server.PlayHandler
$NettyInvocation.execute(PlayHandler.java:237)</pre>
<pre class="stacktrace">at play.Invoker$Invocation.run(Invoker.java:
265)</pre>
<pre class="stacktrace">at play.server.PlayHandler
$NettyInvocation.run(PlayHandler.java:217)</pre>
<pre class="stacktrace">at java.util.concurrent.Executors
$RunnableAdapter.call(Executors.java:441)</pre>
<pre class="stacktrace">at java.util.concurrent.FutureTask
$Sync.innerRun(FutureTask.java:303)</pre>
<pre class="stacktrace">at
java.util.concurrent.FutureTask.run(FutureTask.java:138)</pre>
<pre class="stacktrace">at
java.util.concurrent.ScheduledThreadPoolExecutor
$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)</
pre>
<pre class="stacktrace">at
java.util.concurrent.ScheduledThreadPoolExecutor
$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206)</pre>
<pre class="stacktrace">at java.util.concurrent.ThreadPoolExecutor
$Worker.runTask(ThreadPoolExecutor.java:886)</pre>
<pre class="stacktrace">at java.util.concurrent.ThreadPoolExecutor
$Worker.run(ThreadPoolExecutor.java:908)</pre>
<pre class="stacktrace">at java.lang.Thread.run(Thread.java:680)</
pre>
</div>
</div>

Questions:

1. Why are model objects required to use Scalate with Play?
2. What does "Template file extension missing" mean?

Thanks,

Matt

Matt Raible

unread,
Aug 24, 2011, 9:25:29 PM8/24/11
to Scalate
I've updated to Play 1.2.3 today and I still haven't solved this
issue. Digging through some docs, it looks like render(name) might be
causing this problem. Here's my Application.scala class:

package controllers

import play.mvc._

object Application extends ScalateController {
def index() = {
val name = "Guest user"
render(name)
}
}

This renders the raw HTML I mentioned below.

Digging through some documentation, google queries and such, I found
renderWithScalate(name) and Template(name) might be a better choice.

The former renders the following:

The value for 'name' was not set
org.fusesource.scalate.NoValueSetException: The value for 'name' was
not set

at org.fusesource.scalate.RenderContext$$anonfun$attribute
$1.apply(RenderContext.scala:113)
at org.fusesource.scalate.RenderContext$$anonfun$attribute
$1.apply(RenderContext.scala:113)
at scala.Option.getOrElse(Option.scala:104)
at org.fusesource.scalate.RenderContext
$class.attribute(RenderContext.scala:113)
at
org.fusesource.scalate.DefaultRenderContext.attribute(DefaultRenderContext.scala:
29)
at Application.$_scalate_$index_ssp$.$_scalate_$render(index.ssp.scala:
16)
at Application.$_scalate_$index_ssp.render(index.ssp.scala:31)
at
org.fusesource.scalate.DefaultRenderContext.capture(DefaultRenderContext.scala:
85)
at
org.fusesource.scalate.layout.DefaultLayoutStrategy.layout(DefaultLayoutStrategy.scala:
43)
at org.fusesource.scalate.TemplateEngine$$anonfun$layout$1.apply$mcV
$sp(TemplateEngine.scala:398)
at org.fusesource.scalate.TemplateEngine$$anonfun$layout
$1.apply(TemplateEngine.scala:390)
at org.fusesource.scalate.TemplateEngine$$anonfun$layout
$1.apply(TemplateEngine.scala:390)
at org.fusesource.scalate.RenderContext$.using(RenderContext.scala:45)
at org.fusesource.scalate.TemplateEngine.layout(TemplateEngine.scala:
390)
at org.fusesource.scalate.TemplateEngine.layout(TemplateEngine.scala:
382)
at org.fusesource.scalate.TemplateEngine.layout(TemplateEngine.scala:
427)
at play.mvc.scalate.Provider
$class.renderScalateTemplate(Provider.scala:101)

Using Template(name) results in:

Template not found
The template Guest user does not exist.

Thanks for any advice.

Sean

unread,
Oct 23, 2011, 12:48:32 AM10/23/11
to Scalate
I dug into the source, and it appears that the code and documentation
are not consistent. If you provide a string as the first argument in
the Seq of args you provide, it will assume that is the template name.
I haven't figured out all of the internals, but my advice is to not
provide a string as the first argument until the source can be updated
and released.
Reply all
Reply to author
Forward
0 new messages