Victor Girotto
Victor Girotto

Reputation: 113

Play Framework + Eclipse: undefined method for ReverseApplication

I'm having a little trouble (more like an annoyance, really) when using the Play Framework with Eclipse.

I'm following this tutorial to get started with Play. In a certain moment in the tutorial, it asks us to type in this code:

public static Result index() {
  return redirect(routes.Application.tasks());
}

This works as expected when running the application. The problem is that Eclipse doesn't like it. It says:

The method tasks() is undefined for the type ReverseApplication

While underlining tasks with the dashed red line. Is there a reason for this to happen? I've tried cleaning and compiling the project (through the Play terminal) and refreshing the project in Eclipse, but to no avail.

Is there something I can do about it?

I'm using Eclipse Juno, build 20120606-2254

Thank you so much!

Upvotes: 7

Views: 4187

Answers (5)

IanRae
IanRae

Reputation: 293

The Play command used to be called "eclipsify". It is now called "eclipse".

Generally, I do the following and it works pretty well with Eclipse

-at the start of the day, start the play console in your project dir and do 'clean' and 'run'  
-open a web browser point to the app (localhost:9000)  
-launch eclipse  
-make code changes...  
-Play will rebuild the app whenever code changes occur. So refreshing the app in
   the browser.  
-back in eclipse, Refresh the project to reload the files that play rebuild just made.

Upvotes: 1

geekay
geekay

Reputation: 215

I know it has been a year since @nico_ekito's answer but just wanted to add this. Adding /target/scala-2.10/classes_managed and ensuring that Eclipse automatically refreshes the workspace fixed it for me. Thanks @nico_ekito

Using Eclipse Kepler, play framework 2.2.2

Upvotes: 0

ndeverge
ndeverge

Reputation: 21564

Since the views are Scala code, they are compiled by the Scala compiler (ie your Play console through sbt). So Eclipse cannot compile and find these.

So, your best option is to configure Eclipse so that it automatically refresh the workspace and make sure that the folder "target/scala-2.9.1/classes_managed" is in your build path (it should be done by the "eclipsify" command).

If it does not work after all these steps, try "clean", "compile" and "eclipsify" (for Play 2.0.x) or "eclipse" (for Play 2.1.x) and refresh your projet.

Upvotes: 10

Michael Szczepaniak
Michael Szczepaniak

Reputation: 2140

None of the previous suggestions worked for me, but when I did a refresh on the target folder, the red underlining on my view references went away.

Upvotes: 2

bsmk
bsmk

Reputation: 1347

Close and open your project in Eclipse. This worked for me (Eclipse Juno).

Upvotes: 6

Related Questions