Play Framework Routes not working
Asked Answered
D

3

6

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?

Dupondius answered 23/5, 2013 at 3:30 Comment(7)
No, your routes file looks fine. Could you try restartig your Play application?Dd
Have you started the right application? It seems that there are only 2 routes detected in your route file and those 2 routes are the default routes present in a newly generated project.Galahad
@Dd I have restarted my application.Dupondius
@i.am.michiel, I was thinking the same thing it. It is as if it is not detecting any changes. I definitely started the right application, this is my one and only Play application. I can get the index page to work fine, but none of the login or logout routes work. Any other possible suggestions?Dupondius
Okay let's see...the file is called routes and lies in the conf directory? What happens if you deliberately introduce some syntax errors to the file and then reload (or restart the application)?Dd
Try with play clean-allKirwan
@MaFo, thank you! play clean-all did it!Dupondius
P
8

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
Partlet answered 24/5, 2013 at 11:10 Comment(1)
If you have activator, you can do activator cleanMastaba
J
4

@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.

Judon answered 26/2, 2014 at 20:56 Comment(1)
No, Compile does additional works in the comparison with clean command.Benitobenjamen
S
1

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

  1. sbt clean
  2. activator run
Shoplifter answered 28/6, 2016 at 9:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.