3

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 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
3
  • 1
    hope this helps playframework.org/documentation/1.1.1/scala Commented Mar 7, 2011 at 18:03
  • @Nishant, yeah i've looked at that already, but it doesn't contain anything that helps with my issue. Commented Mar 7, 2011 at 19:34
  • some more info: i did some more testing, and the scala controller works fine when i run the site on my production linux server, but when i try to run it on my dev machine (win7) it doesn't work... not sure what the problem could be. Commented Mar 8, 2011 at 15:38

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

2 Comments

yeah that definitely sounds like my problem. i've already posted on the google group, but i will submit a formal bug report. thanks.
sorry not being able to help more :) They usually answer quickly so it should be solved soon.
3

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.

2 Comments

If the Scala module is working, you don't need to use Blog$ for objects.
yeah based on my new findings, this is not the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.