Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 929
Victor Girotto Avatar asked Jun 22 '12 20:06

Victor Girotto


4 Answers

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.

like image 143
ndeverge Avatar answered Nov 19 '22 22:11

ndeverge


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

like image 22
bsmk Avatar answered Nov 19 '22 22:11

bsmk


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.

like image 2
Michael Szczepaniak Avatar answered Nov 19 '22 23:11

Michael Szczepaniak


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.
like image 1
IanRae Avatar answered Nov 20 '22 00:11

IanRae