Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

play framework unable to run an existing project

I'm a rookie developer trying to run an application using play framework. I've followed the tutorial and can successfully create a new project.

However when I go to the directory that has the project I'm supposed to work on and enter the play command I get the following error:

[error] Not a valid command: play (similar: last, alias, loadp)
[error] Not a valid project ID: play
[error] Not a valid configuration: play
[error] Not a valid key: play (similar: clean)
[error] play

I have very little knowledge regarding the framework and don't know where to start correcting my mistake. Any suggestions ?

like image 453
Pumpkin Avatar asked Mar 31 '12 10:03

Pumpkin


People also ask

How do I run a play Framework project?

To run the tutorial: Unzip the project in a convenient location. In a command window, change to the top-level project directory. Enter sbt run .

How do I import a play framework project into Eclipse?

You then need to import the application into your Workspace with the File/Import/General/Existing project… menu (compile your project first). To debug, start your application with sbt -jvm-debug 9999 run and in Eclipse right-click on the project and select Debug As, Debug Configurations.

What is the browser based IDE that comes with Activator?

“Typesafe Activator is a browser-based or command-line tool that helps developers get started with the Typesafe Reactive Platform.”


2 Answers

You have to run the play command this way:

./play cmd [app_path] [--options]

where in case of running a project, it is

./play run /path/to/projectname
like image 117
bArmageddon Avatar answered Oct 13 '22 17:10

bArmageddon


I am facing this problem in the context of sub projects.

This is what worked for me.


Code:

import sbt._
import sbt.Keys._

object ApplicationBuild extends Build {

  val helloWorldProj = Project(id = "HelloWorld", base = file("helloworld"))    

  val appName = "WebApp"
  val appVersion = "1.0"
  val appDependencies = Seq()

  val webAppProj = PlayProject( appName, appVersion, appDependencies, path = file("webapp"), mainLang = PlayProject.SCALA)
    .dependsOn(helloWorldProj)
    .aggregate(helloWorldProj)

}

On running the play command, I get the following error:

Error:

[info] Set current project to HelloWorld (in build file:/D:/EclipseProjects/HelloWorldPlayMultiProject/)
[error] Not a valid command: play (similar: last, alias, loadp)
[error] Not a valid project ID: play
[error] Not a valid configuration: play
[error] Not a valid key: play (similar: play-hash, play-dist, play-conf)
[error] play
[error]     ^

Solution:

Now, if I rename helloWorldProj as zhelloWorldProj, it works! In this case, play sets the active project to WebApp.(Since webAppProj variable name alphabetically comes before zhelloWorldProj)

I can then change the active project to HelloWorld by giving the command project HelloWorld.

I think this has something to do with how sbt finds the Project objects using reflection.

like image 2
dips Avatar answered Oct 13 '22 17:10

dips