actual argument cannot be converted to

Tag: scala , playframework , playframework-2.1 Author: junjun316666 Date: 2013-04-21

play doesn't convert my java form object to the scala world.

    [error] /home/myproject/split/frontend/app/controllers/frontend/ error: method render in class settings cannot be applied to given types;
    [error]             return ok(settings.render(settingsForm.fill(userSettings)));
    [error]                               ^
    [error]   required:<Settings>
    [error]   found:<Settings>
    [error]   reason: actual argument<Settings> cannot be converted to<Settings> by method invocation conversion

the view-template looks like this:

@(settingsForm: Form[Settings])

@import play.i18n._
@import helper._
@import helper.twitterBootstrap._

@main {

    @helper.form(action = controllers.frontend.routes.Configuration.setSettings) {

Any idea?

I should also mention that we use project split main->frontend->common and main->backend->common. We moved this page (view and controller) from common to frontend. It worked in common fine. Now in frontend I get this error.

I actually had a similar problem with a java.util.List and I had to add templatesImport ++= Seq("java.util._", ... to the settings:

  val frontend = play.Project(
      appName + "-frontend", appVersion, path = file("main/frontend")
      templatesImport ++= Seq("java.util._", "models.frontend._")

I tried with already, didn't help.

Maybe you should try to run play clean to your project and run it again?
did that, didn't help, thanks!
Have it been happen on every of your action method that pass Form? Sorry, I have no idea. I am using play 2.1.1, java 1.7, IntellijIDEA as code editor, and never faced such problem when passing to scala template (
I should have mentioned that we have a project split, I'll edit my post..

Other Answer1

Your frontend project is a Scala project, not a Java project. Add a dependency on javaCore to it, and it will be a Java project. Then do a play clean compile, and everything should work. Eg:

val frontend = play.Project(
  appName + "-frontend", appVersion, Seq(javaCore), path = file("main/frontend")
  templatesImport ++= Seq("java.util._", "models.frontend._")


It did solve the problem. Probably you could reproduce the issue with my dummy project which is available on this link