Scala IDE problems with Play 2.4

2,401 views
Skip to first unread message

Thomas Hii

unread,
Jun 1, 2015, 1:11:51 AM6/1/15
to scala-i...@googlegroups.com
After upgrading to Play 2.4, the views are showing the following errors:

Multiple annotations found at this line:
- Object HtmlFormat is not a member of package play.api.templates
- type Html is not a member of package play.api.templates

Sample view file. The error is shown at the first line:
--------------------------- main.scala.html ---------------------------
@(title: String)(content: Html)

<!DOCTYPE html>

<html>
    <head>
        @header_section(title)
    </head>
   
    <body>
        @main_header()
       
        @content
       
        @main_footer()
    </body>
</html>
---------------------------------------------------------------------------------------

I've changes Play2-> Template default imports to play.twirl.api._ and play.twirl.api.TemplateMagic._, but the problem still persists. Anyone has any idea on how to resolve this?

wpopie...@virtuslab.com

unread,
Jun 1, 2015, 5:29:42 AM6/1/15
to scala-i...@googlegroups.com
Hello Thomas,

let me try to verify it

Regards,
Wieslaw

Mirco Dotta

unread,
Jun 1, 2015, 6:17:37 AM6/1/15
to scala-i...@googlegroups.com
Hi Thomas,

What version of sbteclipse are you using to generate the Eclipse project? (I’m asking because you need to use sbteclipse 4.0.0-RC2)
If you are indeed using 4.0.0-RC2, and you have regenerated your Eclipse project after upgrading to Play 2.4, then it would be useful if you could create a small project that we can use to replicate the issue.

Cheers,
Mirco
----------------
Mirco Dotta - @mircodotta

Typesafe – Build reactive apps!

--
You received this message because you are subscribed to the Google Groups "Scala IDE User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-ide-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scala-ide-user/f18432e0-1e20-4bfa-a3a1-9d630b639b9c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

signature.asc

Thomas Hii

unread,
Jun 3, 2015, 9:06:57 AM6/3/15
to scala-i...@googlegroups.com
Hi Mirco,

I'm already using sbteclipse 4.0.0-RC2 and also generated a small project to test out. The problem still remains. The project that I used for testing can be found here.

https://github.com/dukefirehawk/test-app

brb...@gmail.com

unread,
Jun 5, 2015, 10:51:48 AM6/5/15
to scala-i...@googlegroups.com
Hi Mirco,
I still get this problem in Scala IDE 4.1.0-vfinal-20150525-1102-Typesafe with an out-of-the-box project created using the latest activator: 
(Play 2.4.0)

I just did:
- activator new hello
- appended addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "4.0.0-RC2") to project/plugins.sbt
- activator eclipse
- activator run (to generate sources for routes and views)
- imported the project in Scala IDE
- manually added the source directories "target/scala-2.11/routes/main" and "target/scala-2.11/twirl/main" to the classpath (I had to)

Now I get errors on view.index.scala.html:

ambiguous reference to overloaded definition, both method _display_ in class BaseScalaTemplate of type (o: Any)(implicit m: Manifest[<error>])<error> and  method _display_ in class BaseScalaTemplate of type (x: <error>)<error> match argument types (play.twirl.api.HtmlFormat.Appendable) and expected result type Any Error occurred in an application involving default arguments.

type Html is not a member of package play.api.templates

object HtmlFormat is not a member of package play.api.templates

Please help, this is really frustrating.

Thanks,
Marco
 

Mirco Dotta

unread,
Jun 6, 2015, 12:55:09 PM6/6/15
to scala-i...@googlegroups.com
I just did exactly as you said, and it all worked fine for me (no errors are reported in Eclipse for me).

Also, if you run `activator compile` *before* `activator eclipse`, then your classpath will be set correctly (this may be a bug in sbteclipse, I’ll have to check).

----------------
Mirco Dotta - @mircodotta

Typesafe – Build reactive apps!

--
You received this message because you are subscribed to the Google Groups "Scala IDE User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-ide-use...@googlegroups.com.
signature.asc

Mirco Dotta

unread,
Jun 6, 2015, 12:59:49 PM6/6/15
to scala-i...@googlegroups.com
Hi Thomas,

It works fine for me. I’m really not sure why we are seeing different behaviours.

May I suggest that you guys try to download a fresh Scala IDE installation http://scala-ide.org/download/sdk.html, and import the project in a new workspace.

— Mirco
----------------
Mirco Dotta - @mircodotta

Typesafe – Build reactive apps!

--
You received this message because you are subscribed to the Google Groups "Scala IDE User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-ide-use...@googlegroups.com.
signature.asc

brb...@gmail.com

unread,
Jun 7, 2015, 6:27:41 AM6/7/15
to scala-i...@googlegroups.com
Hi Mirco,

- activator new hello
- appended addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "4.0.0-RC2") to project/plugins.sbt
- activator compile
- activator eclipse
- launched Scala IDE, created a new workspace and imported the project

The problem is still there. The workspace finishes building without problems, but when I open views in Scala IDE (e.g., view.index.scala.html) I get the aforementioned errors.

-- Marco

Mirco Dotta

unread,
Jun 8, 2015, 9:26:51 AM6/8/15
to scala-i...@googlegroups.com
Hi Marco,

Yes, you are absolutely right, and I’m really sorry for the time I made both you and Thomas waste.

The problem is definitely there, and I’m not really sure what’s happening. I’m going to try to debug it now.

— Mirco
----------------
Mirco Dotta - @mircodotta

Typesafe – Build reactive apps!

signature.asc

Mirco Dotta

unread,
Jun 8, 2015, 10:11:50 AM6/8/15
to scala-i...@googlegroups.com
Alright, I found the issue.

The easy way to fix it is to change the import here


to be play.twirl.api.Html and play.twirl.api.HtmlFormat.

However, we can’t simply make this change as we would be breaking Play 2.3 projects. Hence, we need to add some logic to switch the imports based on the Play version.

Also, it’s strange that adding these imports in the Play2 dialog doesn’t work. Hence, there may also be an issue with https://github.com/scala-ide/scala-ide-play2/blob/master/org.scala-ide.play2/src/org/scalaide/play2/PlayProject.scala#L23-L25


— Mirco
----------------
Mirco Dotta - @mircodotta

Typesafe – Build reactive apps!

signature.asc

Mirco Dotta

unread,
Jun 8, 2015, 12:00:06 PM6/8/15
to scala-i...@googlegroups.com
Alright, I found the issue.

The easy way to fix it is to change the import here


to be play.twirl.api.Html and play.twirl.api.HtmlFormat.

These are not imports, but hardcoded types.


However, we can’t simply make this change as we would be breaking Play 2.3 projects. Hence, we need to add some logic to switch the imports based on the Play version.

Also, it’s strange that adding these imports in the Play2 dialog doesn’t work. Hence, there may also be an issue with https://github.com/scala-ide/scala-ide-play2/blob/master/org.scala-ide.play2/src/org/scalaide/play2/PlayProject.scala#L23-L25

Hence, changing the imports can't fix the problem.
signature.asc

Thomas Hii

unread,
Jun 10, 2015, 4:51:45 AM6/10/15
to scala-i...@googlegroups.com
Hi Mirco,

Thanks for the explanation. Will poke around in the code to see if can get it working locally.

Mirco Dotta

unread,
Jun 10, 2015, 9:57:25 AM6/10/15
to scala-i...@googlegroups.com
It’s easy to get it working. Just change the package of the types highlighted in https://github.com/scala-ide/scala-ide-play2/blob/master/org.scala-ide.play2/src/org/scalaide/play2/templateeditor/compiler/CompilerUsing.scala#L48-L49 to be play.twirl.api. That should work for both Play 2.3 and Play 2.4 projects, but not for Play 2.2.


----------------
Mirco Dotta - @mircodotta

Typesafe – Build reactive apps!

signature.asc

brb...@gmail.com

unread,
Jun 10, 2015, 10:23:49 AM6/10/15
to scala-i...@googlegroups.com
Hi Mirco,
So, the only way to use Scala IDE with the current version of Play is to recompile Scala IDE itself?
Are you planning a nightly build to fix this issue?

Thanks for helping,
Marco

Mirco Dotta

unread,
Jun 10, 2015, 11:10:19 AM6/10/15
to scala-i...@googlegroups.com
Yep, at the moment there is no workaround.

As for fixing the issue, I’ll see if I can find time. It might take a while before I get to it, so feel free to hack around and send a PR ;-)

— Mirco
----------------
Mirco Dotta - @mircodotta

Typesafe – Build reactive apps!

signature.asc

András Terray

unread,
Jun 11, 2015, 3:55:55 AM6/11/15
to scala-i...@googlegroups.com
Hello Guys,

I am new in Play! and Scala IDE but I have the same problem as mentioned in this thread but the solution is not clear for me. (Play 2.4, Scala IDE 4.1.0-vfinal)
As I see I should change something in scala-ide-play2 project as Mirco mentioned but it is really not obvious to me how to do it.
Can you tell me how to get the source (as it is in git maybe I need just fork/clone it) and how to compile it? And finally where to put the result?

Thanks for the clarification,
András

Christian Rataj-Weinreben

unread,
Jun 12, 2015, 4:47:01 AM6/12/15
to scala-i...@googlegroups.com
Hi Andras,
as Mirco wrote -> apply the changes he mentioned and compile the project. I did this already:
Building the project is very simple - explained here: https://github.com/scala-ide/scala-ide-play2

So the following steps have to be done:
#1 Fork the scala-ide-play2 project and apply the changes - or use my forked version
#2 Checkout the project locally 
#3 Execute ./build.sh in root of the project folder (wait and drink a cup of coffee while it downloads the internet)
#4 When finished switch to Eclipse and open the "Install New Software..." Dialog (Menu "Help>Install New Software...") 
#5 The build script creates a update site - so select "Add" in the dialog and then "Local..." and switch to the folder "scala-ide-play2/org.scala-ide.play2.update-site/target/site"
#6 Install the feature in this folder

Christian Rataj-Weinreben

unread,
Jun 12, 2015, 4:47:34 AM6/12/15
to scala-i...@googlegroups.com
Hi Mirco,
are the default imports in 
still OK? Or should the import "play.api.templates._" be changed to "play.twirl.api._"

Regards
Christian

Mirco Dotta

unread,
Jun 12, 2015, 7:52:51 AM6/12/15
to scala-i...@googlegroups.com
TBH, I’m wondering if the imports are actually needed. The Twirl compiler (which Scala IDE Play support is using) seems to already inject both imports on every generated template source. Maybe I’ve missed something, but I think it’d be worth trying to remove the additional imports and see if things keep working as expected.

By the way, I’ve pushed a commit that outlines how I think we should try to fix the issue. I’m sharing it with the hope that someone will pick it up. See this branch https://github.com/dotta/scala-ide-play2/tree/issue/249-bad-imported-types-in-play24-views, and in particular the commit https://github.com/dotta/scala-ide-play2/commit/566a8a910763cb73a0f6dc96ab7b81b8b47c7a84.

— Mirco
----------------
Mirco Dotta - @mircodotta

Typesafe – Build reactive apps!

signature.asc

Thomas Hii

unread,
Jun 15, 2015, 1:17:26 AM6/15/15
to scala-i...@googlegroups.com
Hi,

After making the changes as Mirco suggested, finally got the views working. However, I could not patch SCALA IDE by uninstalling the "Play 2 support in SCALA IDE 0.4.6" and replacing it with the patched version. For some unknown reason, Eclipse keeps complaining about a newer version already exists.

As for scala ide plugin compilation, have to comment out a test case org.scalaide.play2.templateeditor.lexical.complexTokeniseTest() for successful compilation. Yet to figure out why the test failed.

Ended up just getting a clean version of Eclipse Luna, installed SCALA IDE plugin minus the Play 2 support and then install the patched version of Play 2 Support. So far so good.

Mirco Dotta

unread,
Jun 15, 2015, 1:29:53 AM6/15/15
to scala-i...@googlegroups.com
Hi Thomas,

Good you got it working.

On my side, I’ve been doing some more work on a proper fix. I don’t think I’m too far from opening a PR, but then again I’m doing this in my free time so it’s not easy to give an estimate of when it will be ready. If anyone is up for working together, here is my branch https://github.com/dotta/scala-ide-play2/tree/issue/249-bad-imported-types-in-play24-views Feel free to fork and contribute back.

----------------
Mirco Dotta - @mircodotta

Typesafe – Build reactive apps!

--
You received this message because you are subscribed to the Google Groups "Scala IDE User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-ide-use...@googlegroups.com.
signature.asc

Christian Rataj-Weinreben

unread,
Jun 15, 2015, 1:55:25 AM6/15/15
to scala-i...@googlegroups.com
Hi Thomas,
on solution (which I used) would be to simply replace the not working version of the Play plugin with the new compiled version. You can copy it to the Eclipse plugin folder and use the same name as the old one. Works for me.

@Mirco - Next week I have some time to help you resolve the problem.

Mirco Dotta

unread,
Jun 15, 2015, 3:05:22 AM6/15/15
to scala-i...@googlegroups.com
Hi Thomas,
on solution (which I used) would be to simply replace the not working version of the Play plugin with the new compiled version. You can copy it to the Eclipse plugin folder and use the same name as the old one. Works for me.

@Mirco - Next week I have some time to help you resolve the problem.

Fantastic!

I’ll keep you updated if I happen to do any further work on it.


Am Montag, 15. Juni 2015 07:17:26 UTC+2 schrieb Thomas Hii:
Hi,

After making the changes as Mirco suggested, finally got the views working. However, I could not patch SCALA IDE by uninstalling the "Play 2 support in SCALA IDE 0.4.6" and replacing it with the patched version. For some unknown reason, Eclipse keeps complaining about a newer version already exists.

As for scala ide plugin compilation, have to comment out a test case org.scalaide.play2.templateeditor.lexical.complexTokeniseTest() for successful compilation. Yet to figure out why the test failed.

Ended up just getting a clean version of Eclipse Luna, installed SCALA IDE plugin minus the Play 2 support and then install the patched version of Play 2 Support. So far so good.

-- 
You received this message because you are subscribed to the Google Groups "Scala IDE User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-ide-use...@googlegroups.com.
signature.asc

Thomas Hii

unread,
Jun 15, 2015, 4:53:23 AM6/15/15
to scala-i...@googlegroups.com
Hi Christian,

Initially I tried your method on scala-SDK-4.1.0-vfinal-2.11-win32.win32.x86_64. After replacing just the jar file in the plugin folder and renaming it to the same name as the original one, the "New Template Editor" option disappeared from the "Open With" option. Odd problem. So ended up doing what I did to get it working until the patch is officially released.

The plugin compilation was done with the following option "mvn -Peclipse-luna -Pscala-ide-stable -Pscala-2.11.x clean verify".

Christian Rataj-Weinreben

unread,
Jun 25, 2015, 5:11:32 AM6/25/15
to scala-i...@googlegroups.com
Hi Thomas,
I have updated my scala-ide-play2 fork on https://github.com/cweinreben/scala-ide-play2.
The version number of the Play2 plugin is now 0.4.7-SNAPSHOT . 
Now updating the plugin locally works. Also the "New Template Editor" option is still available. I have tested the solution with Eclipse Mars.

#2 Compile the whole project using the build.sh in the root of the project
#3 When compiled successfully use the update site in the folder <path to your repo>/scala-ide-play2/org.scala-ide.play2.update-site/target/site/
#4 Now eclipse should find a newer version > 0.4.7.local-....

David Rissato Cruz

unread,
Sep 4, 2015, 2:12:55 AM9/4/15
to Scala IDE User
I have the same problem.

Using:
- scala-SDK-4.1.1-vfinal-2.11-macosx.cocoa.x86_64.zip
- typesafe-activator: stable 1.3.5 (installed using brew install typesafe-activator)

Guido Maresca

unread,
Sep 8, 2015, 1:00:50 AM9/8/15
to Scala IDE User
Me as well, play2 plugin v0.50

tom....@gmail.com

unread,
Sep 17, 2015, 9:37:57 AM9/17/15
to Scala IDE User
I have the same problem as well, with the latest play 2.4.3 and the latest download of the scala IDE. Takes me right back to the bad old days of java web app development in eclipse....

Ivan Schuetz

unread,
Sep 17, 2015, 9:37:57 AM9/17/15
to Scala IDE User
Hello,

I also have the same problem. 

Happens in:
Scala IDE Build id: 4.1.0-vfinal-20150525-1102-Typesafe

As well as in the last version:

Build id: 4.1.1-vfinal-20150727-1320-Typesafe


Plugin:
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "4.0.0")

Content if template is only this:

@(tokenId: String, passwordsForm: Form[(String, String)])(implicit request: RequestHeader)

Simon Schäfer

unread,
Sep 17, 2015, 10:12:06 AM9/17/15
to scala-i...@googlegroups.com


On 09/12/2015 03:25 AM, tom....@gmail.com wrote:
I have the same problem as well, with the latest play 2.4.3 and the latest download of the scala IDE. Takes me right back to the bad old days of java web app development in eclipse....
We are working on resolving this problem. We are going to let you know once it is finished.

On Monday, June 1, 2015 at 6:11:51 AM UTC+1, Thomas Hii wrote:
After upgrading to Play 2.4, the views are showing the following errors:

Multiple annotations found at this line:
- Object HtmlFormat is not a member of package play.api.templates
- type Html is not a member of package play.api.templates

Sample view file. The error is shown at the first line:
--------------------------- main.scala.html ---------------------------
@(title: String)(content: Html)

<!DOCTYPE html>

<html>
    <head>
        @header_section(title)
    </head>
   
    <body>
        @main_header()
       
        @content
       
        @main_footer()
    </body>
</html>
---------------------------------------------------------------------------------------

I've changes Play2-> Template default imports to play.twirl.api._ and play.twirl.api.TemplateMagic._, but the problem still persists. Anyone has any idea on how to resolve this?
--
You received this message because you are subscribed to the Google Groups "Scala IDE User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-ide-use...@googlegroups.com.

Guido Maresca

unread,
Sep 17, 2015, 11:05:02 AM9/17/15
to Scala IDE User
Could you consider adding the following import?

play.mvc.Http.Context.Implicit._ 

Since usually the play templates contain it.

Guido Maresca

unread,
Sep 17, 2015, 12:48:03 PM9/17/15
to Scala IDE User
Thank you so much, the success of this framework for me is also thanks to  your efforts.

Guido


Il giorno giovedì 17 settembre 2015 15:12:06 UTC+1, Simon Schäfer ha scritto:

wpopie...@virtuslab.com

unread,
Sep 18, 2015, 4:11:11 AM9/18/15
to Scala IDE User
Guido,

I think you can add it on Play preferences page as well. The main problem with our Play plugin is that Play has changed the version of Twirl lib in 2.4. So to support 2.3 and 2.4 we need to use twirl parser and compiler coming from different lib version (1.1.1 for 2.4 and 1.0.4 for 2.3). It still under construction.

W.

Guido Maresca

unread,
Sep 18, 2015, 4:17:25 AM9/18/15
to Scala IDE User
Yes I know I can import it there, but I thought since it is a standard import for play templates in the framework itself, maybe it could make sense to have it in the eclipse template as well, that's all!

Thank you.

G

Mirco Dotta

unread,
Sep 22, 2015, 12:58:18 AM9/22/15
to scala-i...@googlegroups.com

----------------
Mirco Dotta - @mircodotta

Typesafe – Build reactive apps!

signature.asc

Guido Maresca

unread,
Sep 22, 2015, 4:37:29 AM9/22/15
to Scala IDE User
Thank you Mirco, so maybe it is a good idea to have it in the plugin's default import as well for java projects?

Mirco Dotta

unread,
Sep 22, 2015, 5:01:47 AM9/22/15
to scala-i...@googlegroups.com
I think it’s a good idea.

Having said that, this is a different problem than the one originally discussed in this thread. If you’d like to discuss it further, it would be better to create a new thread. 

Cheers,
Mirco

P.S. The play eclipse plugin needs contributors, so if feature X is missing and that annoys you, please consider contributing ;-)
----------------
Mirco Dotta - @mircodotta

Typesafe – Build reactive apps!

signature.asc

Guido Maresca

unread,
Sep 22, 2015, 5:25:04 AM9/22/15
to Scala IDE User
Oh I would be glad to contribute, is there a guide on the how? Like lifecycle, pull requests and all? I am a bit new!

wpopie...@virtuslab.com

unread,
Sep 22, 2015, 6:01:12 AM9/22/15
to Scala IDE User
Twirl lib Play2 Plugin dependency pull request is here: https://github.com/scala-ide/scala-ide-play2/pull/253. Ready for review.
Regards
W.

Mirco Dotta

unread,
Sep 22, 2015, 10:55:22 AM9/22/15
to scala-i...@googlegroups.com
Awesome! Here you go https://github.com/scala-ide/scala-ide-play2/blob/master/CONTRIBUTING.md

And use the scala-ide-dev ML for discussing implementation ideas, or if you have any question.

— Mirco

----------------
Mirco Dotta - @mircodotta

Typesafe – Build reactive apps!

signature.asc

Simon Schäfer

unread,
Oct 16, 2015, 6:19:30 AM10/16/15
to Scala IDE User
Hello everyone,

A new version of the play-ide has been released. It should resolve all of the problems that were discussed in this thread. Please check for updates in your Eclipse installations and let us know if you encounter further problems.

Simon
Reply all
Reply to author
Forward
0 new messages