Re: [play-framework] Play 2.1-RC1 / Scala 2.9.2 / Eclipse Juno

620 views
Skip to first unread message

James Roper

unread,
Jan 2, 2013, 10:36:34 PM1/2/13
to play-framework
Somewhat new to Scala but have been using other languages and have a few questions regards environment and Play 2.1.
I am using Ubuntu 12.10 with the Scala 2.9.2 and Java 7 installed.

The Scala distribution that you installed in Ubuntu is irrelevant.  Play uses SBT.  SBT downloads whatever version of Scala is required by the project it is building, and in Play 2.1, that version is 2.10.  In fact SBT does that for all of the dependencies in your project.
 
One of my several questions below is regards which version of Scala is being referred to and how do I change that?

The version of Scala in 2.1-RC1 is 2.10.0-RC1.  You can't change it.  Changing it will cause issues because different versions of Scala (particularly in the release candidate stage) are not likely to be binary compatible.  Changing it would require recompiling Play itself.
 
Eclipse Juno seems to refer to Scala 2.9.3 and 'play compile' to Scala 2.10 however I have Scala 2.9.2 installed.

Again, the version of Scala that you have installed in Ubuntu is irrelevant to Eclipse too.  How are you creating your Eclipse project?  Using the play eclipse command?  If that's so, Eclipse should be using Scala 2.10.0-RC1 for your project.
 
4. It would be nice to be able to create a project with name such as json.21. The .21 generates an error on 'play compile':

at xsbt.boot.Boot$.main(Boot.scala:20)
at xsbt.boot.Boot.main(Boot.scala)
Caused by: java.lang.RuntimeException: Invalid project ID: Expected ID character
json.21
              ^
at scala.sys.package$.error(package.scala:27)
at scala.Predef$.error(Predef.scala:123)
at sbt.Project$$anonfun$apply$2.apply(Project.scala:153)

It would allow for more flexibility with naming projects and such. if possible to make this possible would be great.

The fact that Play let you create a project with a dot in it is a bug that I fixed just the other day, Play won't let you do this anymore, it will prompt you to enter a new one.  Projects can't have names with dots in them because SBT uses ivy to manage dependencies, and ivy has strict rules on project names.  This is because the project name isn't just an arbitrary description, it's a unique identifier that is used for dependency management.  Just like hostnames have strict rules over what's a legal character, so does Ivy on its project names.
 
5. I have been working through the examples in Play for Scala and the examples that use JSON (Ch 8/ 10) compiles fine in Play 2.0.4 however generates error on compile (as well as Eclipse) as such:

        "ean" -> Json.toJson(p.ean),
        * class file needed by DefaultWrites is missing. reference type 
ClassTag of package reflect refers to nonexisting symbol.

I looked through the documentation of play.api.libs.json.toJson - seems like the method definition has not changed.

The way Play does Json has changed majorly between 2.0 and 2.1.  For the most up to date docs, please see here:

 

...
Thank you very much for your help.

Monosij

--
 
 



--
James Roper
Software Engineer

Typesafe - The software stack for applications that scale
Twitter: @jroper

Sarvesh Kumar Singh

unread,
Jan 3, 2013, 3:11:52 AM1/3/13
to play-fr...@googlegroups.com
I think that eclipse is not able to resolve all the required dependencies for a play application.

try,

$ play
[Your App]$ eclipsify with-source=true

and import it as a play project.

On Thursday, 3 January 2013 00:15:48 UTC+5:30, Monosij Dutta-Roy wrote:

Hello - 

Somewhat new to Scala but have been using other languages and have a few questions regards environment and Play 2.1.
I am using Ubuntu 12.10 with the Scala 2.9.2 and Java 7 installed.
One of my several questions below is regards which version of Scala is being referred to and how do I change that?
Eclipse Juno seems to refer to Scala 2.9.3 and 'play compile' to Scala 2.10 however I have Scala 2.9.2 installed.

Thank you upfront for your help with my questions below. Again, new to Scala and Play but not to programming.

...
1. I generate a play 2.1 project for Scala and Eclipse project as well. When I import into Eclipse (Juno) I see an error in the default Application.scala it generates in:

  def list = Action { ... )
  ** Multiple markers at this line
- class file needed by BodyParser is missing. reference type Either 
of object package refers to nonexisting symbol.
It however compiles fine from the command line and runs as well.
Wondering why this error happens? I am using Ubuntu 12.10 with Scala 2.9.2 installed.

...
2. This question may not be for this forum but somewhat related.

I am using the Scala plugin from Scala lang. In there there does not seem to be a way to set which Scala compiler to use such as for Python, R where I can set which version of Python or R to use.
For example when I import the Play project into Eclipse it says it is using Scala library 2.9.3-20121217-...
However my installation of Ubuntu has Scala 2.9.2 - so where is it getting 2.9.3 from?
I went to the Project Propoerties / Scala compiler settings and in Advanced tab for Xpluginsdir got the value: /opt/development/ide/eclipse-jee-scala/configuration/org.eclipse.osgi/bundles/842/1/.cp/lib
How do i use Scala 2.10-RC1 that I have unzipped an installed in a separate directory?

...
3. When I execute 'play compile' on the project I do get:

[info] Set current project to json21 (in build file:/space/code.trials/Play.21/json21/)
[info] Compiling 7 Scala sources and 1 Java source to /space/code.trials/Play.21/json21/target/scala-2.10/classes...

So here it is using Scala 2.1 - where is this 2.10 version coming from - from within Play-2.1-RC1?

I am a little confused by the different versions being referenced Scala 2.9.3 (from Eclipse) and Scala 2.10 from 'play compile' when I have installed in Ubuntu Scala 2.9.2.

...
4. It would be nice to be able to create a project with name such as json.21. The .21 generates an error on 'play compile':

at xsbt.boot.Boot$.main(Boot.scala:20)
at xsbt.boot.Boot.main(Boot.scala)
Caused by: java.lang.RuntimeException: Invalid project ID: Expected ID character
json.21
              ^
at scala.sys.package$.error(package.scala:27)
at scala.Predef$.error(Predef.scala:123)
at sbt.Project$$anonfun$apply$2.apply(Project.scala:153)

It would allow for more flexibility with naming projects and such. if possible to make this possible would be great.

...
5. I have been working through the examples in Play for Scala and the examples that use JSON (Ch 8/ 10) compiles fine in Play 2.0.4 however generates error on compile (as well as Eclipse) as such:

        "ean" -> Json.toJson(p.ean),
        * class file needed by DefaultWrites is missing. reference type 
ClassTag of package reflect refers to nonexisting symbol.

I looked through the documentation of play.api.libs.json.toJson - seems like the method definition has not changed.

Monosij Dutta-Roy

unread,
Jan 6, 2013, 12:56:14 AM1/6/13
to play-fr...@googlegroups.com
Thank you for your help. I installed the right plugin. Now Eclipse displays fine.

On Thursday, January 3, 2013 10:57:23 PM UTC-5, Nick Stoughton wrote:
I had a similar problem when upgrading from play 2.0 to 2.1 ... you need to uninstall the eclipse scala-ide plugin and install the 2.10 RC1 plugin from http://download.scala-ide.org/sdk/e38/scala210/dev/site/

Otherwise "play compile" builds the project just fine, but Eclipse has squiggly red lines in way too many places!
Reply all
Reply to author
Forward
0 new messages