[2.0] how to start application from play console

3,849 views
Skip to first unread message

sas

unread,
Apr 1, 2012, 11:10:22 AM4/1/12
to play-framework
I'm playing with play console (it's and amazing tool!)

when I try to use some object that uses the db I get the following
error:

scala> val db = models.Contact.all
java.lang.RuntimeException: There is no started application

so how can I start the app?

(I tried starting the app from another console, but it -rather
obviously- didn't work ;-)

saludos

sas



sas

unread,
Apr 1, 2012, 11:11:57 AM4/1/12
to play-framework
offtopic: I'm pretty sure I entered the question with the "[2.0]"
prefix, but somehow it got lost... it's not the first time that this
happens...

peter hausel

unread,
Apr 1, 2012, 12:11:11 PM4/1/12
to play-fr...@googlegroups.com
----------------------------------------------------------
$ play console
[info] Loading project definition from /Users/phausel/workspace/play2/samples/java/comet-clock/project
[info] Set current project to comet-clock (in build file:/Users/phausel/workspace/play2/samples/java/comet-clock/)
[info] Updating {file:/Users/phausel/workspace/play2/samples/java/comet-clock/}comet-clock...
[info] Done updating.                                                                  
[info] Compiling 4 Scala sources and 1 Java source to /Users/phausel/workspace/play2/samples/java/comet-clock/target/scala-2.9.1/classes...
[info] Starting scala interpreter...
[info] 
Welcome to Scala version 2.9.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_29).
Type in expressions to have them evaluated.
Type :help for more information.

scala> import play.core.StaticApplication
import play.core.StaticApplication

scala> new StaticApplication(new java.io.File("."))
[info] play - Application started (Prod)
res0: play.core.StaticApplication = play.core.StaticApplication@75a0941a
-----------------------------

after this you should be able to interact with your app.

sas

unread,
Apr 1, 2012, 12:40:17 PM4/1/12
to play-framework
Thanks peter! great tip

This should be on the front-page of play framework site! it really is
a great feature

I think we need something like http://www.playframework.org/documentation/1.2.4/5things
for play2

maybe also adding a shortcut, like play console-app or something like
that...

saludos

sas

sas

unread,
Apr 1, 2012, 1:40:50 PM4/1/12
to play-framework
Well, I couldn't help blogging about it

http://playlatam.wordpress.com/2012/04/01/play-framework-2-quicktip-interactively-play-with-your-application-from-the-scala-console/



On 1 abr, 13:40, sas <open...@gmail.com> wrote:
> Thanks peter! great tip
>
> This should be on the front-page of play framework site! it really is
> a great feature
>
> I think we need something likehttp://www.playframework.org/documentation/1.2.4/5things

GrailsDeveloper

unread,
Apr 1, 2012, 2:04:17 PM4/1/12
to play-fr...@googlegroups.com
Wrote '[2.0] the first [] was hidden by google. See my postings in  https://groups.google.com/forum/?fromgroups&hl=de#!topic/play-framework/gConfp6PjXc 

sas

unread,
Apr 2, 2012, 3:13:01 PM4/2/12
to play-framework
I started playing with the computer-dabase sample project, and I'm
really surprised at all the things you can do with play console

I found several limitations with the java version (I guess it's the
netbeans voodoo magic), but with the scala + anorm I can do
everything...

The only limitation I found so far is how to pass an implicit request,
for example trying this:

scala> views.html.list(page, 1, "%")

<console>:23: error: could not find implicit value for parameter
flash: play.api.mvc.Flash
views.html.list(page, 1, "%")

Is there some way I could pass the request?

saludos

sas


On 1 abr, 15:04, GrailsDeveloper <opensourc...@googlemail.com> wrote:
> Wrote '[2.0] the first [] was hidden by google. See my postings in  https://groups.google.com/forum/?fromgroups&hl=de#!topic/play-framewo...

Guillaume Bort

unread,
Apr 2, 2012, 3:58:40 PM4/2/12
to play-fr...@googlegroups.com
You can use the Fake* helper from the play.api.test library. FakeFlash
is available.

> --
> You received this message because you are subscribed to the Google Groups "play-framework" group.
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.
>

--
Guillaume Bort

sas

unread,
Apr 2, 2012, 9:53:24 PM4/2/12
to play-framework
thanks a lot for the tip

I tried it, but in the console I have no access to play.api.test nor
play.test, so I can't get to FakeApplication or FakeRequest

I guess I should add something to the classpath...

I peeked into project/Build.scala and I see that playconsole uses src/
console, and test src/play-test, and there you have defined play.test
for java, and play.api.test for scala

is there some way I could include those projects from the console?
Reply all
Reply to author
Forward
0 new messages