Play Framework Routes not working

12,469

Solution 1

Looks like the routes file wasn't compiled properly. probably, you should do a clean in the play console and try again

$ play clean-all

Solution 2

@DiAlex

Just in case play clean-all doesn't work, you can try to

$ clean 

then

$ compile

within the play console.

However, I think both of them do the same thing.

Solution 3

If you are using play framework via Activator you can simply do the follow steps:

  1. sbt clean
  2. activator run
Share:
12,469
Bert B.
Author by

Bert B.

Updated on June 09, 2022

Comments

  • Bert B.
    Bert B. almost 2 years

    I am just trying to follow along with the ZenTasks tutorial (http://www.playframework.com/documentation/2.1.0/JavaGuide4) for the Play Framework. I can't seem to even get the Login page to work however.

    I am running this project with the play ~run command. When navigating to http://localhost:9000/login the error is

    Action not found For request 'GET /login'
    These routes have been tried, in this order:
    1 GET/controllers.Application.index()
    2 GET/assets/$file<.+>controllers.Assets.at(path:String = "/public", file:String)`
    

    My routes file looks like

    # Routes
    # This file defines all application routes (Higher priority routes first)
    # ~~~~
    
    # Home page
    GET     /                           controllers.Application.index()
    
    # User athentication
    GET     /login                      controllers.Application.login()
    POST    /login                      controllers.Application.authenticate()
    GET     /logout                     controllers.Application.logout()
    
    # Map static resources from the /public folder to the /assets URL path
    GET     /assets/*file               controllers.Assets.at(path="/public", file)
    

    and the Application.login, authenticate, and logout functions all compile properly. Am I missing something incredibly easy here, because I can't tell what is going wrong?

  • Iruku Kagika
    Iruku Kagika almost 7 years
    If you have activator, you can do activator clean
  • Mohammadreza Khatami
    Mohammadreza Khatami over 5 years
    No, Compile does additional works in the comparison with clean command.