This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Scala Eclipse plugin problems

6 replies
ScottC 2
Joined: 2011-01-30,
User offline. Last seen 42 years 45 weeks ago.

I'm having several problems with Eclipse + Scala.

The goal: To get scala to work in our current environment so we can
write unit tests with Scala against Java projects. If this goes well,
we might start to use some Scala in production code.

The problem: This just isn't working in our environment -- multi-
module maven projects, some webapps, with maven +m2eclipse + eclipse.
Adding Scala leads to several problems including eclipse crashes and
significantly more memory consumed.

Environment:

* Maven 3.0.1 in a ~20 module project. Some modules are webapps
(type 'war') most are regular java projects.
* Scala added to test scope for one of the modules, works by command
line maven.
* Eclipse Helios (3.6) latest update with WTP (for webapps)
** m2Eclipse plugin
** m2Eclipse WTP integration
** subversive SVN plugin
** Scala Helios plugin (http://download.scala-ide.org/nightly-update-
helios-2.8.1.final)
** Scala m2Eclipse integration (http://www.assembla.com/wiki/show/
scala-ide/With_M2Eclipse)

After all the components are installed, I add the Scala Nature to the
project. I then have several issues. I have tried the "Maven >
Update Project Configuration" option which often helps fix the WTP
integration's glitches, but that has no effect on the Scala issues.

Here are the issues:
A large number of my Java classes suddeny get "red x's" as a "Scala
Problem" is highlighted on the source. These problems are of three
forms:
* An import in a Java class imports an inner class from another
package: "InnerClassName is not a member of
_root_.com.foo.bar.ContainingClassName"
* A static import has similar issues at times, but with the method
being imported: "createMock is not a member of
org.easymock.classextension.EasyMock"
* Completely valid Java generics get an error: "Illegal cyclic
reference involving type V" -- for example with a Java class declared
as public class OrderedMultiMap>

If there are any things I can do to prevent the scala plugin from
marking errors in my perfectly valid Java files, that would be
helpful.
Why does Scala process these java source files, isn't that the Java
compiler's job? Note, this is a Java 1.6 project, I don't know if
that has anything to do with it. Second, it appears to be applying
Scala rules to the imports and type declaration in Java classes. Is
it reading the class files and applying Scala rules to that? The
above three things wouldn't be in a class file generated by Scala, as
far as I can tell.

Next, is a potential killer: Every time I change and save a *.scala
file, it kicks off a "Building Workspace" task, that takes between 15
seconds and 3 minutes on this collection of projects. Note, this is a
big set of related projects with a few thousand java classes across
them. It is as if there is no incremental compile or that is broken
somehow.
Many times, changing a scala class ends up causing an _infinite loop_
of compiling, that never completes. "Building workspace" runs to
100%, then starts over again. Sometimes, this can be stopped if I
force clean all projects in eclipse (which takes a few minutes ...).
But about half the time I have to restart eclipse to stop it.
These are killers because any gains from a more productive language
are lost if the dev tools incur an extra hour or two a day of waiting
and stopping/starting the dev environment.
The number of situations that cause a full re-build with just Java in
eclipse in the same setup is very small.

Next, running JUnit tests can't be done on individual files by right-
clicking the file and doing "run as >> JUnit test". That is probably
the JUnit plugin's fault, but if there was a way to get that to work
it would be very helpful. It works fine for most Java classes, but
not at all for Scala. I can't even highlight and right click a
function tagged with @Test in the class and run it -- another thing
that works easily in Java.

The last set of issues are stability related. Memory consumption in
eclipse is up about 100MB and others who have tried out this have
reported Eclipse crashes -- one quote "I hadn't had Eclipse crash in
weeks, and after installing the Scala plugin today it crashed 3
times". I have not seen a crash, but have seen the extra memory
consumed. There is no smoking gun here or direct line of evidence,
but its not helping mind-share around here.

Before anyone asks: No, Eclipse 3.5 is not an option, it does not
function with Maven + WTP projects.

Does anyone else have similar issues or means to mitigate/avoid them?
If I can't work around most of the above, Scala looks like its not
something we can integrate into current Java projects with the current
state of Eclipse tooling.

tolsen77
Joined: 2008-10-08,
User offline. Last seen 1 year 38 weeks ago.
Re: Scala Eclipse plugin problems

I remember reading Scala for Eclipse had problems when used with
web-development plugins (can't find the reference on the Scala IDE
wiki). I tested Eclipse with Aptana plugin a while back and I just
couldn't get it to work, so I just figured the same restriction still
applied. Other than Eclipse, it seems people have good success with the
latest Idea in mixed Java/Scala projects.

On memory problems: did you try
https://www.assembla.com/wiki/show/scala-ide/FAQ

On Sun, 30 Jan 2011 15:01 -0800, "ScottC" wrote:
> I'm having several problems with Eclipse + Scala.
>
> The goal: To get scala to work in our current environment so we can
> write unit tests with Scala against Java projects. If this goes well,
> we might start to use some Scala in production code.
>
> The problem: This just isn't working in our environment -- multi-
> module maven projects, some webapps, with maven +m2eclipse + eclipse.
> Adding Scala leads to several problems including eclipse crashes and
> significantly more memory consumed.
>
> Environment:
>
> * Maven 3.0.1 in a ~20 module project. Some modules are webapps
> (type 'war') most are regular java projects.
> * Scala added to test scope for one of the modules, works by command
> line maven.
> * Eclipse Helios (3.6) latest update with WTP (for webapps)
> ** m2Eclipse plugin
> ** m2Eclipse WTP integration
> ** subversive SVN plugin
> ** Scala Helios plugin (http://download.scala-ide.org/nightly-update-
> helios-2.8.1.final)
> ** Scala m2Eclipse integration (http://www.assembla.com/wiki/show/
> scala-ide/With_M2Eclipse)
>
> After all the components are installed, I add the Scala Nature to the
> project. I then have several issues. I have tried the "Maven >
> Update Project Configuration" option which often helps fix the WTP
> integration's glitches, but that has no effect on the Scala issues.
>
> Here are the issues:
> A large number of my Java classes suddeny get "red x's" as a "Scala
> Problem" is highlighted on the source. These problems are of three
> forms:
> * An import in a Java class imports an inner class from another
> package: "InnerClassName is not a member of
> _root_.com.foo.bar.ContainingClassName"
> * A static import has similar issues at times, but with the method
> being imported: "createMock is not a member of
> org.easymock.classextension.EasyMock"
> * Completely valid Java generics get an error: "Illegal cyclic
> reference involving type V" -- for example with a Java class declared
> as public class OrderedMultiMap>
>
> If there are any things I can do to prevent the scala plugin from
> marking errors in my perfectly valid Java files, that would be
> helpful.
> Why does Scala process these java source files, isn't that the Java
> compiler's job? Note, this is a Java 1.6 project, I don't know if
> that has anything to do with it. Second, it appears to be applying
> Scala rules to the imports and type declaration in Java classes. Is
> it reading the class files and applying Scala rules to that? The
> above three things wouldn't be in a class file generated by Scala, as
> far as I can tell.
>
> Next, is a potential killer: Every time I change and save a *.scala
> file, it kicks off a "Building Workspace" task, that takes between 15
> seconds and 3 minutes on this collection of projects. Note, this is a
> big set of related projects with a few thousand java classes across
> them. It is as if there is no incremental compile or that is broken
> somehow.
> Many times, changing a scala class ends up causing an _infinite loop_
> of compiling, that never completes. "Building workspace" runs to
> 100%, then starts over again. Sometimes, this can be stopped if I
> force clean all projects in eclipse (which takes a few minutes ...).
> But about half the time I have to restart eclipse to stop it.
> These are killers because any gains from a more productive language
> are lost if the dev tools incur an extra hour or two a day of waiting
> and stopping/starting the dev environment.
> The number of situations that cause a full re-build with just Java in
> eclipse in the same setup is very small.
>
> Next, running JUnit tests can't be done on individual files by right-
> clicking the file and doing "run as >> JUnit test". That is probably
> the JUnit plugin's fault, but if there was a way to get that to work
> it would be very helpful. It works fine for most Java classes, but
> not at all for Scala. I can't even highlight and right click a
> function tagged with @Test in the class and run it -- another thing
> that works easily in Java.
>
> The last set of issues are stability related. Memory consumption in
> eclipse is up about 100MB and others who have tried out this have
> reported Eclipse crashes -- one quote "I hadn't had Eclipse crash in
> weeks, and after installing the Scala plugin today it crashed 3
> times". I have not seen a crash, but have seen the extra memory
> consumed. There is no smoking gun here or direct line of evidence,
> but its not helping mind-share around here.
>
> Before anyone asks: No, Eclipse 3.5 is not an option, it does not
> function with Maven + WTP projects.
>
> Does anyone else have similar issues or means to mitigate/avoid them?
> If I can't work around most of the above, Scala looks like its not
> something we can integrate into current Java projects with the current
> state of Eclipse tooling.
>
>

david.bernard
Joined: 2009-01-08,
User offline. Last seen 1 year 27 weeks ago.
Re: Scala Eclipse plugin problems

On Mon, Jan 31, 2011 at 03:36, Trond Olsen wrote:
> I remember reading Scala for Eclipse had problems when used with
> web-development plugins (can't find the reference on the Scala IDE
> wiki). I tested Eclipse with Aptana plugin a while back and I just
> couldn't get it to work, so I just figured the same restriction still
> applied. Other than Eclipse, it seems people have good success with the
> latest Idea in mixed Java/Scala projects.

I did some Lift dev with ScalaIDE and Aptana (stubio 3 beta), without trouble.
But never try with WTP.
There are ticket open Scala + WTP, and other about m2eclipse-scala +
m2eclipse-WTP, but I didn't spend time on it.

For my info, what are the feature of WTP ?

> On memory problems: did you try
> https://www.assembla.com/wiki/show/scala-ide/FAQ
>
> On Sun, 30 Jan 2011 15:01 -0800, "ScottC" wrote:
>> I'm having several problems with Eclipse + Scala.
>>
>> The goal:  To get scala to work in our current environment so we can
>> write unit tests with Scala against Java projects.  If this goes well,
>> we might start to use some Scala in production code.
>>
>> The problem:  This just isn't working in our environment -- multi-
>> module maven projects, some webapps, with maven +m2eclipse + eclipse.
>> Adding Scala leads to several problems including eclipse crashes and
>> significantly more memory consumed.

see https://www.assembla.com/wiki/show/scala-ide/Setup
yes scala need lot of memory and there are some memory leak (some will
be fixed in scalac 2.9.0)
give a try to the wip_exp_backport version (some user prefer it)
update-site :
http://download.scala-ide.org/nightly-update-wip-exp-backport-2.8.1.final

>>
>> Environment:
>>
>> * Maven 3.0.1  in a ~20 module project.  Some modules are webapps
>> (type 'war') most are regular java projects.
>> * Scala added to test scope for one of the modules, works by command
>> line maven.
>> * Eclipse Helios (3.6) latest update with WTP (for webapps)
>> ** m2Eclipse plugin
>> ** m2Eclipse WTP integration
>> ** subversive SVN plugin
>> ** Scala Helios plugin (http://download.scala-ide.org/nightly-update-
>> helios-2.8.1.final)
>> ** Scala m2Eclipse integration (http://www.assembla.com/wiki/show/
>> scala-ide/With_M2Eclipse)
>>
>> After all the components are installed, I add the Scala Nature to the
>> project.  I then have several issues.  I have tried the "Maven >
>> Update Project Configuration" option which often helps fix the WTP
>> integration's glitches, but that has no effect on the Scala issues.
>>
>> Here are the issues:
>> A large number of my Java classes suddeny get "red x's" as a "Scala
>> Problem" is highlighted on the source.  These problems are of three
>> forms:
>> * An import in a Java class imports an inner class from another
>> package: "InnerClassName is not a member of
>> _root_.com.foo.bar.ContainingClassName"
>> * A static import has similar issues at times, but with the method
>> being imported: "createMock is not a member of
>> org.easymock.classextension.EasyMock"
>> * Completely valid Java generics get an error:  "Illegal cyclic
>> reference involving type V" -- for example with a Java class declared
>> as public class OrderedMultiMap>
>>
>> If there are any things I can do to prevent the scala plugin from
>> marking errors in my perfectly valid Java files, that would be
>> helpful.
>> Why does Scala process these java source files, isn't that the Java
>> compiler's job?

For Scala project, Scala builder replace Java builder and embed it.
I have *some very simple* mixed java/scala project, and I don't have this issue.

Can you provide a sample project, and open a ticket ?
https://www.assembla.com/spaces/scala-ide/tickets (need to be
registered + watcher)

>>  Note, this is a Java 1.6 project, I don't know if
>> that has anything to do with it.  Second, it appears to be applying
>> Scala rules to the imports and type declaration in Java classes.  Is
>> it reading the class files and applying Scala rules to that?  The
>> above three things wouldn't be in a class file generated by Scala, as
>> far as I can tell.
>>
>> Next, is a potential killer:  Every time I change and save a *.scala
>> file, it kicks off a "Building Workspace" task, that takes between 15
>> seconds and 3 minutes on this collection of projects.  Note, this is a
>> big set of related projects with a few thousand java classes across
>> them.  It is as if there is no incremental compile or that is broken
>> somehow.

Currently, There is no incremental in cross project.

>> Many times, changing a scala class ends up causing an _infinite loop_
>> of compiling, that never completes.  "Building workspace"  runs to
>> 100%, then starts over again. Sometimes, this can be stopped if I
>> force clean all projects in eclipse (which takes a few minutes ...).
>> But about half the time I have to restart eclipse to stop it.
>> These are killers because any gains from a more productive language
>> are lost if the dev tools incur an extra hour or two a day of waiting
>> and stopping/starting the dev environment.

the wip_exp_backport version should increase the user experience, but not a lot.

>> The number of situations that cause a full re-build with just Java in
>> eclipse in the same setup is very small.
>>
>> Next, running JUnit tests can't be done on individual files by right-
>> clicking the file and doing "run as >> JUnit test".  That is probably
>> the JUnit plugin's fault, but if there was a way to get that to work
>> it would be very helpful.  It works fine for most Java classes, but
>> not at all for Scala.  I can't even highlight and right click a
>> function tagged with @Test in the class and run it -- another thing
>> that works easily in Java.

It should work. (for better experience use keyboard shortcut, else
eclipse will ask every launcher if they can run the file, in the case
of scala => having a compiled class (in memory)
I should go off-line, I'll reply to the end later (If I can) or tomorrow.
the scala eclipse mailing list is a better place
http://groups.google.com/group/scala-ide-user

/davidB

>> The last set of issues are stability related.  Memory consumption in
>> eclipse is up about 100MB and others who have tried out this have
>> reported Eclipse crashes -- one quote "I hadn't had Eclipse crash in
>> weeks, and after installing the Scala plugin today it crashed 3
>> times".  I have not seen a crash, but have seen the extra memory
>> consumed.  There is no smoking gun here or direct line of evidence,
>> but its not helping mind-share around here.
>>
>> Before anyone asks:  No, Eclipse 3.5 is not an option, it does not
>> function with Maven + WTP projects.
>>
>> Does anyone else have similar issues or means to mitigate/avoid them?
>> If I can't work around most of the above, Scala looks like its not
>> something we can integrate into current Java projects with the current
>> state of Eclipse tooling.
>>
>>
>

hedefalk
Joined: 2008-09-24,
User offline. Last seen 1 year 5 weeks ago.
Re: Scala Eclipse plugin problems
> For my info, what are the feature of WTP ?
I think the main thing here is to be a able to deploy to a connected server. You add a server to Eclipse where WTP sets the webapp folder hidden in your workspace, something like:
/dev/workspaces/indigo/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/dfkka/WEB-INF

Then Eclipse copies files from target/classes out to this directory. This in itself might be worth much more than "ln -s" but what it allows me to do with plugins:
m2eclipsem2eclipse wtp-integrationjrebel wtp integration
is this:
I can have a multimodule projects where say Webproject is dependent on JarProject and a change in JarProject is immediately seen in the browser with incremental compilation. Something like that would not be possible with say mvn jetty:run since it uses the installed jars for deps. I tried with some maven-jetty-plugin settings like <extraClasspath>, but they don't seem to work.
I just tried this out with scala-ide (feeling brave) but it seems the classpath entries used by wtp breaks the compiler:
http://scala-ide-portfolio.assembla.com/spaces/scala-ide/tickets/1000552-scala-reflect-internal-types$typeerror---and-then-incremental-compilation-stops-

If anybody know a way to get that kind of turnaround I would be really happy to hear!

Thanks,Viktor
hedefalk
Joined: 2008-09-24,
User offline. Last seen 1 year 5 weeks ago.
Re: Scala Eclipse plugin problems
Hm, I think my mind is getting dull. I really don't think WTP gives me anything. The same thing is achievable just by adding rebel.xml:s in the deps and use say mvn jetty:run.
My thought was that first the old installed jars will be used but then JRebel will hot-deploy on change. However, on a restart, it will go back to the old installed one again. That's a small gain by WTP in my book. But that doesn't seem to be so I noticed. Even if I restart the server the new classes will be picked up. I wonder where JRebel put those? Ah, maybe it provides the monitored target-directories as classpath entries above the jars. Probably, right?
Anyway, I actually got everything working with WTP now, but WTP is so annoying I think I'll ditch it again ;)
The error above I think was due to double scala-library.jar:s.
Thanks and sorry for any misinformation,Viktor
Matthew Farwell
Joined: 2011-08-11,
User offline. Last seen 34 weeks 5 days ago.
Re: Scala Eclipse plugin problems
For a full explanation of how JRebel works, you can see the following:
http://stackoverflow.com/questions/4826958/how-does-jrebel-work http://www.zeroturnaround.com/jrebel/faq/#How_does_jrebel_work
Essentially, it extends existing classloaders to first search for .class files in the monitored directories. I'd recommend reading the How does jrebel work, because it's interesting. And useful as well.
For the Eclipse WTP, I've been using it with mixed Java/Scala projects for a while, and while I've seen problems, most of them are to do with maven/eclipse integration and general wierdness with how the projects are set up.
Cordialement,
Matthew.

2011/8/10 Viktor Hedefalk <hedefalk [at] gmail [dot] com>
Hm, I think my mind is getting dull. I really don't think WTP gives me anything. The same thing is achievable just by adding rebel.xml:s in the deps and use say mvn jetty:run.
My thought was that first the old installed jars will be used but then JRebel will hot-deploy on change. However, on a restart, it will go back to the old installed one again. That's a small gain by WTP in my book. But that doesn't seem to be so I noticed. Even if I restart the server the new classes will be picked up. I wonder where JRebel put those? Ah, maybe it provides the monitored target-directories as classpath entries above the jars. Probably, right?
Anyway, I actually got everything working with WTP now, but WTP is so annoying I think I'll ditch it again ;)
The error above I think was due to double scala-library.jar:s.
Thanks and sorry for any misinformation,Viktor

david.bernard
Joined: 2009-01-08,
User offline. Last seen 1 year 27 weeks ago.
Re: Scala Eclipse plugin problems
Hi,
I forgot to say that I used RunWebapp.scala [1] to run/debug the webapp from eclipse like a regular main class, it's probably why I never try WTP.I also used it with eclipse the JRebel plugin sometimes. I rarely used mvn jetty:run. But I thinks it's "easy" to create a custom m2eclipse target to run it.

[1] https://github.com/davidB/vscaladoc2_www/blob/master/src/test/scala/RunWebApp.scala
/davidB

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland