Eclipse unresolved symbol with Play Framework
Asked Answered
S

4

8

I'm a beginner user of Play Framework 2.1.3 and I have just created a new Java application and I have run play eclipse to generate the eclipse project for it. I have also tested so that it works by doing a play run.

So I'm following this tutorial and there is a step where you should add this piece of code:

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

But I'm getting the message "routes cannot be resolved". I have also tried play compile and in Eclipse doing a clean to no avail.

Seoul answered 2/9, 2013 at 14:22 Comment(5)
possible duplicate of Play Framework + Eclipse: undefined method for ReverseApplicationAileneaileron
After running play eclipse did you refresh the project in Eclipse? (right click project name and select refresh)Entrenchment
The framework and eclipse integration is buggy, running eclipse and reimporting the project again seems to fix these things. It's a major pita.See
Try this solution: #17807447Buchenwald
did my solution work for you? would be great if you could select an answer or provide the one that worked for you :)Fatal
B
16

I was having the same trouble after the recent 2.4.X release of Play and the solution of cleaning/compiling/reimporting wasn't working. The solution for me was to:

  1. Add the below keys to build.sbt
  2. Kill eclipse
  3. ./activator clean
  4. ./activator compile
  5. ./activator eclipse
  6. Re-import into eclipse

The problem is basically that the managed source directory wasn't being created, these lines fix the problem.

 EclipseKeys.projectFlavor := EclipseProjectFlavor.Java           // Java project. Don't expect Scala IDE
 EclipseKeys.createSrc := EclipseCreateSrc.ValueSet(EclipseCreateSrc.ManagedClasses, EclipseCreateSrc.ManagedResources)  // Use .class files instead of generated .scala files for views and routes 
 EclipseKeys.preTasks := Seq(compile in Compile)                  // Compile the project before generating Eclipse files, so that .class files for views and routes are present
Bedside answered 4/7, 2015 at 3:54 Comment(2)
This almost works, but for a Scala project you need only the EclipseKeys.preTasks line in your build.sbt. Further information is available in the Play documentation for 2.4.x. playframework.com/documentation/2.4.x/IDEHalleyhalli
Thank you! This is the correct way of doing it for Java only projects.Balenciaga
F
5
  1. run play clean-all from your project directory
  2. run play eclipse from your project directory
  3. refresh your eclipse project
Fatal answered 14/1, 2014 at 18:23 Comment(0)
P
0

Upgrade sbteclipse to version 5.1.0 (which was released on January 12th 2017) - it fixes this bug.

Platus answered 13/1, 2017 at 11:27 Comment(0)
C
-2

Probably some kind of classpath issue in your Eclipse setup. Anyway, you should not rely on Eclipse to compile your Play application, simply compile it from the console and use Eclipse for source code editing only. (BTW : there are way lighter IDEs then Eclipse if you don't use it for compilation)

Crossgarnet answered 2/9, 2013 at 14:25 Comment(1)
Even if one only wants to use Eclipse (or way lighter IDE) for pure editing joy, if Eclipse can't find some dependency, then Eclipse becomes mute and dumb.Procurer

© 2022 - 2024 — McMap. All rights reserved.