Play! framework - views aren't compiled?
Asked Answered
M

7

7

I created a new project and working with eclipse (used eclipsify command).
basically, I moved the app directory from an old project to the new one I created.

the problem is that eclipse doesn't recognize the views. I get errors like:

views.html.viewTopic cannot be resolved to a type

I tried to play compile but it didn't help.
so I got 40 errors. all of them connected to the fact that the views aren't compiled and therefore, the eclipse doesn't recognize them (my guess of course).

what can I do?
by the way, the old project compiled and ran without a problem (I used intellij)

Mansour answered 21/9, 2012 at 11:20 Comment(2)
possible duplicate of Playframework - Eclipse can't detect a new templateGlorify
Also, make sure Eclipse is refreshing filesystem changes automatically. See: scala-ide.org/docs/tutorials/play20scalaide20/index.html ("Configure Eclipse so changes on the file system are automatically picked up")Urnfield
G
0

The best you can do is just search the Stack Overflow as this topic was discussed really many times.

Glorify answered 21/9, 2012 at 12:29 Comment(5)
ok, I've seen something strange. in src_managed directory there is no models directory although there should be. there's only controllers and views. why is that?Mansour
Did you check what controllers and views contains? most prbably in first you have only routes.java - in second html files compiled into scala functions. There are no controller's or model's classes, so yes it looks normal.Glorify
I run the command play idea and now using intellij but still, same problem. intellij does not recognize those views.html files.Mansour
Really strange, I'm working with Idea and it recognizes views just view seconds after recompilingGlorify
this is what I did. I created a new project. after that, I copied an old app directory (with all the sub-dirs - views, models, controllers). I compiled and ran the project. very strange indeed...Mansour
W
5

For Java Play Framework v2.4.6 (activator v1.3.7) with Eclipse Mars:

So that you will not have a "can not resolve error" with your viewTopic.render(), you can add this <classpathentry kind="lib" path="target/scala-2.11/classes"/> to your .classpath or right-click on your project -> Build Path -> Configure Build Path -> Add Class Folder and make it point to target/scala-2.11/classes.

Wreak answered 8/2, 2016 at 16:0 Comment(1)
You are great.. I have tried to solve this problem for more than 2 hours and your solution works :)Keto
S
3
  • Run 'play eclipse' on the command line
  • In Eclipse, refresh your Project via hitting F5
Specialism answered 9/1, 2014 at 16:46 Comment(0)
J
2

Re-run the command in play console with the sources this time:
$ eclipse with-source=true

And then go to eclipse and clean your project and build all

Jacksnipe answered 11/1, 2014 at 13:47 Comment(0)
P
1

According to jetbrains, the issue with templates is fixed. If you have play 2 generated source sources included in the IDEA project then you should exclude this folder from the project

http://www.jetbrains.com/idea/webhelp/configuring-folders-within-a-content-root.html

and do File | Invalidate caches and restart.

If you have an SBT project, open it in IDEA via File | Import Project | Sbt type project

Make sure to use the latest Scala and Play 2 plugins.

Porterhouse answered 30/1, 2014 at 10:5 Comment(0)
C
1
  1. Close eclipse project
  2. activator eclipse
  3. activator compile
  4. Open eclipse project
  5. Add target/scala-[your-version-here]/classes to your build path as a class folder
Cenesthesia answered 19/6, 2018 at 14:21 Comment(0)
G
0

The best you can do is just search the Stack Overflow as this topic was discussed really many times.

Glorify answered 21/9, 2012 at 12:29 Comment(5)
ok, I've seen something strange. in src_managed directory there is no models directory although there should be. there's only controllers and views. why is that?Mansour
Did you check what controllers and views contains? most prbably in first you have only routes.java - in second html files compiled into scala functions. There are no controller's or model's classes, so yes it looks normal.Glorify
I run the command play idea and now using intellij but still, same problem. intellij does not recognize those views.html files.Mansour
Really strange, I'm working with Idea and it recognizes views just view seconds after recompilingGlorify
this is what I did. I created a new project. after that, I copied an old app directory (with all the sub-dirs - views, models, controllers). I compiled and ran the project. very strange indeed...Mansour
M
0

OK, I solved it.

  • I created a new app again
  • moved app dir
  • only then ran the command play idea
Mansour answered 21/9, 2012 at 15:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.