How to resolve reference to twirl generated template class in Scala-IDE?

603 views
Skip to first unread message

biswanath chinta

unread,
Dec 30, 2014, 12:31:39 AM12/30/14
to scala-i...@googlegroups.com

Using twirl for generating template class. Everything is working fine with sbt and the webpages are rendering.

I am using Scala-IDE for development. And in the Scala-IDE the reference to the template class i.e. "html.test()", test is the template name, is showing as an error.

This is the error:

Description Resource Path Location Type

missing or invalid dependency detected while loading class file 'test.class'. Could not access term api in value .twirl, because it (or its dependencies) are missing. Check your build definition for missing or conflicting dependencies. (Re-run with -Ylog-classpath to see the problematic classpath.) A full rebuild may help if 'test.class' was compiled against an incompatible version of .twirl. ApiService.scala /api/src/main/scala/com/komma/api/rest line 97 Scala Problem.

I did a clean and it is giving "not found: value html" error now.

Is there any way to resolve this error in the scala IDE ?

Thanks.

Matan Safriel

unread,
Jan 11, 2015, 8:15:16 AM1/11/15
to scala-i...@googlegroups.com
You might want to re-import the project from sbt, through the sbt command sbt eclipse if you are used to the sbt eclipse plugin. There's something about Scala IDE not automatically updating as you add templates, if I am not mistaken.

Mirco Dotta

unread,
Jan 11, 2015, 11:14:36 PM1/11/15
to scala-i...@googlegroups.com
Not sure what I’m going to say is the right solution to your issue, but I guess it’s worth a try.

I assume you are using Play 2.3 and have installed the Play support for Eclipse. Try adding target/scala-2.11/twirl/main as a source in your project’s build path (right click on the the project in the Eclipse Package Explorer, then Java Build Path, Source tab, Add Folder).

— Mirco

--
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/1196caeb-0869-435d-8767-fc5f0f773014%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nils Weinander

unread,
Feb 2, 2015, 8:34:57 AM2/2/15
to scala-i...@googlegroups.com
I (and my colleagues) have had the same problem and this works. But, shouldn't this source entry be generated by

activator eclipse

then?

Mirco Dotta

unread,
Feb 2, 2015, 9:09:44 AM2/2/15
to scala-i...@googlegroups.com
Hi Nils,

Indeed, it should. There will be a fix for this issue in the next release of Play! (v2.4.0). Here is a link to the fix already pushed in master https://github.com/playframework/playframework/commit/4782e9862002a7ee6b5f834836a3e54fd69de9c9

Therefore, in the near future, executing `activator eclipse` will correctly set all the source folders.

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

Nils Weinander

unread,
Feb 2, 2015, 12:03:59 PM2/2/15
to scala-i...@googlegroups.com
That's great news Mirco, thanks! And now that we know the workaround, there is no problem waiting for the fix.

Matan Safriel

unread,
Feb 3, 2015, 10:37:20 AM2/3/15
to scala-i...@googlegroups.com
Thank you all, I had the same problem (only a bit worse), and this solves it for me too! 
One technical comment for anyone else who may search for this: 

The way to add the twirl main to a project in latest version ScalaIDE (as installed out of the box) is a bit different with a Scala play project, in case it helps anyone:

  1. Right click the project
  2. "Build path"
  3. "Configure build path..."
  4. Tab "Source"
  5. "Add folder"
  6. Expand target --> scala-2.11 --> twirl --> main and tick "main"
  7. Voila
I noticed also that ScalaIDE is a bit stricter than sbt in compiling imports of model packages, whereas it looks like the compilation with sbt is less restrictive in that... i.e. if you nest a model under models but declare it a different package than "models", sbt will perfectly work, but ScalaIDE will fail to import it into a controller however I tried. I guess unless ScalaIDE used sbt for its compilation of play projects, these things may continue to pop-up.

Thanks anyway,
Matan

Naftoli Gugenheim

unread,
Feb 3, 2015, 9:12:25 PM2/3/15
to scala-i...@googlegroups.com
It does use the sbt builder. The problem is that to do IDE stuff it has to know where to find things. So in general IIUC if packages don't follow directory structure scala IDE will be confused.

Regarding twirl, I think you should be able to do something like right-click twirl/main, Build Path, Add to Build Path or something.

biswanath chinta

unread,
Feb 4, 2015, 12:01:36 PM2/4/15
to scala-i...@googlegroups.com
Thanks for all the helpful replies. 

Matan Safriel

unread,
Feb 5, 2015, 1:05:30 PM2/5/15
to scala-i...@googlegroups.com
Naftoli, I still get a lot of incremental compilation friction in ScalaIDE which I don't get in SBT. It may seem sbt is more permissive (or better at guessing, whichever point of view you prefer) than ScalaIDE. Plus, sometimes ScalaIDE will provide fantom errors. E.g. I create one class in a package, move it to another source file in the same package, and ScalaIDE thinks it's a duplicate even after I use eclipse's clean and rebuild command. Sbt ~compile on the other hand just recompiles well on every case.... this is just one example

--
You received this message because you are subscribed to a topic in the Google Groups "Scala IDE User" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/scala-ide-user/rS6YmjJb8Aw/unsubscribe.
To unsubscribe from this group and all its topics, 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/a2e8036f-0e15-4ede-8785-bee0086ce845%40googlegroups.com.

Naftoli Gugenheim

unread,
Feb 5, 2015, 2:16:39 PM2/5/15
to scala-i...@googlegroups.com
Is it errors in the Problems view, or just in the editor, that eclipse has but sbt not?

Matan Safriel

unread,
Feb 5, 2015, 3:23:11 PM2/5/15
to scala-i...@googlegroups.com
Editor. This has just been an unprofessional rant. I don't have the energy to take care of reproducibility. 
Apologies.

Naftoli Gugenheim

unread,
Feb 5, 2015, 5:06:27 PM2/5/15
to scala-i...@googlegroups.com
Right, so the editor is very different than actually building. I think some of these are known issues, not sure about the moving the class. Basically sbt technology is better than the editor's situation.

Simon Schäfer

unread,
Feb 5, 2015, 7:57:29 PM2/5/15
to scala-i...@googlegroups.com

On 02/05/2015 11:06 PM, Naftoli Gugenheim wrote:
> Right, so the editor is very different than actually building. I think
> some of these are known issues, not sure about the moving the class.
> Basically sbt technology is better than the editor's situation.
The IDE contains an additional cache for the presentation compiler. In
case of the moving class, this cache is not correctly refreshed hence
the error message of the duplicate definition. I think, because it is
just an error in the presentation compiler, you should be able to run
the code in the IDE. But that doesn't change anything about the fact
that such errors are annoying.

It is possible to restart the presentation compiler (and clean its cache
by doing so) by right clicking on the project and selecting Scala >
restart presentation compiler.

Matan Safriel

unread,
Feb 6, 2015, 4:23:59 AM2/6/15
to scala-i...@googlegroups.com
Thanks, good to know! 
I wonder how does the presentation compiler need to be different than sbt; in both, it seems the task can be summed up as fast incremental compilation. So I wonder what is the fundamental difference I am missing. 

--
You received this message because you are subscribed to a topic in the Google Groups "Scala IDE User" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/scala-ide-user/rS6YmjJb8Aw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to scala-ide-user+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scala-ide-user/54D41178.8020301%40antoras.de.

Simon Schäfer

unread,
Feb 6, 2015, 7:12:48 AM2/6/15
to scala-i...@googlegroups.com

On 02/06/2015 10:23 AM, Matan Safriel wrote:
Thanks, good to know! 
I wonder how does the presentation compiler need to be different than sbt; in both, it seems the task can be summed up as fast incremental compilation. So I wonder what is the fundamental difference I am missing.
The presentation compiler doesn't produce any binaries because that would slow it down too much. sbt on the other hand is "just" a tool to make producing binaries easier - for an IDE only useful for its building part.

Beside from that there is no difference - they both use scalac internally for the compilation process.

On Fri, Feb 6, 2015 at 2:57 AM, Simon Schäfer <ma...@antoras.de> wrote:

On 02/05/2015 11:06 PM, Naftoli Gugenheim wrote:
Right, so the editor is very different than actually building. I think some of these are known issues, not sure about the moving the class. Basically sbt technology is better than the editor's situation.
The IDE contains an additional cache for the presentation compiler. In case of the moving class, this cache is not correctly refreshed hence the error message of the duplicate definition. I think, because it is just an error in the presentation compiler, you should be able to run the code in the IDE. But that doesn't change anything about the fact that such errors are annoying.

It is possible to restart the presentation compiler (and clean its cache by doing so) by right clicking on the project and selecting Scala > restart presentation compiler.


--
You received this message because you are subscribed to a topic in the Google Groups "Scala IDE User" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/scala-ide-user/rS6YmjJb8Aw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to scala-ide-use...@googlegroups.com.

--
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.
Reply all
Reply to author
Forward
0 new messages