Adding Scala module to existing Java project
So I have a rather large Play! project using the standard Java stuff. I want to start using Scala and thought I could combine the two. I installed the scala module and added the config line. I then added a new controller like so:
package controllers
import play.mvc._
object Blog extends Controller {
def index = "test"
}
But when i restart the server and try to browse to http://localhost:9000/Blog/index i get "Blog.index action not found"
Is there something else I need to do to add Scala support to this project or must I create a new project with Scala from the get go and copy over all the files?
UPDATE
routes:
# Routes
# This file defines all application routes (Higher priority routes first)
# ~~~~
# Home 开发者_Python百科page
GET /explorer Application.index
GET /signup Application.signUp
POST /register Application.register
GET /tour Main.tour
GET / Main.homePage
# Map static resources from the /app/public folder to the /public path
GET /public/ staticDir:public
* /admin module:crud
# Catch all
* / module:secure
* /{controller}/{action} {controller}.{action}
logs:
@65kk1d8dn
Blog.index action not found
Action not found
Action Blog.index could not be found. Error raised is Controller controllers.Blog not found
play.exceptions.ActionNotFoundException: Action Blog.index not found
at play.mvc.ActionInvoker.getActionMethod(ActionInvoker.java:447)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:78)
at Invocation.HTTP Request(Play!)
Caused by: java.lang.Exception: Controller controllers.Blog not found
... 3 more
did you check the routes file? It contains the route to your controller/action? And is the server starting without any error?
It seems to me an error in routes file, could you add your config and the full error message you are seeing?
EDIT(after routes added):
mm I'm afraid your problem is Windows (obvious answer from your comment above, I know). I've seen a few issues in the Play Google group, all related to Windows. As Scala support is still a bit "experimental" to a certain degree, I just believe you stomped on a bug. I would create a ticket with the Play team.
Because, for whatever reason*, it's not Blog.index
, it's Blog$.index()
.
- I assume it's something about the way companion objects in Scala become classes in the JVM.
精彩评论