I am using scala IDE eclipse version 4.4.0 with Scala 2.11.8. I am able to compile the project from command line using sbt compile and create eclipse specific project files using sbt eclipse (using sbteclipse for this). However , while I am clicking on build project in context menu ,its giving exception
**Errors occurred during the build.
Errors running builder 'Scala Builder' on project project_name.
org.eclipse.core.internal.resources.File cannot be cast to org.eclipse.core.resources.IContainer**
Here the error log of the same .
**!ENTRY org.scala-ide.sdt.core 4 0 2017-01-09 14:13:56.020
!MESSAGE Error thrown while initializing the presentation compiler.
!STACK 0
java.lang.ClassCastException: org.eclipse.core.internal.resources.File cannot be cast to org.eclipse.core.resources.IContainer
at org.scalaide.core.internal.project.ScalaProject$$anonfun$sourceOutputFolders$2$$anonfun$apply$7.apply(ScalaProject.scala:242)
at org.scalaide.core.internal.project.ScalaProject$$anonfun$sourceOutputFolders$2$$anonfun$apply$7.apply(ScalaProject.scala:232)
at scala.Option$WithFilter.map(Option.scala:207)
at org.scalaide.core.internal.project.ScalaProject$$anonfun$sourceOutputFolders$2.apply(ScalaProject.scala:232)
at org.scalaide.core.internal.project.ScalaProject$$anonfun$sourceOutputFolders$2.apply(ScalaProject.scala:231)
at scala.collection.TraversableLike$WithFilter$$anonfun$flatMap$2.apply(TraversableLike.scala:714)
at scala.collection.immutable.List.foreach(List.scala:381)
at scala.collection.TraversableLike$WithFilter.flatMap(TraversableLike.scala:713)
at org.scalaide.core.internal.project.ScalaProject.sourceOutputFolders(ScalaProject.scala:231)
at org.scalaide.core.internal.project.ScalaProject.initializeCompilerSettings(ScalaProject.scala:478)
at org.scalaide.core.internal.project.ScalaProject.org$scalaide$core$internal$project$ScalaProject$$prepareCompilerSettings(ScalaProject.scala:435)
at org.scalaide.core.internal.project.ScalaProject$$anonfun$5.apply(ScalaProject.scala:159)
at org.scalaide.core.internal.project.ScalaProject$$anonfun$5.apply(ScalaProject.scala:159)
at org.scalaide.core.internal.compiler.PresentationCompilerProxy.liftedTree1$1(PresentationCompilerProxy.scala:152)
at org.scalaide.core.internal.compiler.PresentationCompilerProxy.create(PresentationCompilerProxy.scala:151)
at org.scalaide.core.internal.compiler.PresentationCompilerProxy.initialize(PresentationCompilerProxy.scala:116)
at org.scalaide.core.internal.compiler.PresentationCompilerProxy.obtainPc$1(PresentationCompilerProxy.scala:78)
at org.scalaide.core.internal.compiler.PresentationCompilerProxy.internal(PresentationCompilerProxy.scala:98)
at org.scalaide.core.internal.jdt.model.ScalaCompilationUnit$class.addToIndexer(ScalaCompilationUnit.scala:157)
at org.scalaide.core.internal.jdt.model.ScalaSourceFile.addToIndexer(ScalaSourceFile.scala:66)
at org.scalaide.core.internal.jdt.search.ScalaSourceIndexer$$anonfun$indexDocument$2.apply(ScalaSourceIndexer.scala:16)
at org.scalaide.core.internal.jdt.search.ScalaSourceIndexer$$anonfun$indexDocument$2.apply(ScalaSourceIndexer.scala:16)
at scala.Option.map(Option.scala:146)
at org.scalaide.core.internal.jdt.search.ScalaSourceIndexer.indexDocument(ScalaSourceIndexer.scala:16)
at scala.tools.eclipse.contribution.weaving.jdt.indexerprovider.IndexerProviderAspect.ajc$around$scala_tools_eclipse_contribution_weaving_jdt_indexerprovider_IndexerProviderAspect$1$16276a3c(IndexerProviderAspect.aj:30)
at org.eclipse.jdt.internal.core.search.JavaSearchParticipant.indexDocument(JavaSearchParticipant.java:71)
at org.eclipse.jdt.internal.core.search.indexing.IndexManager.indexDocument(IndexManager.java:504)
at org.eclipse.jdt.internal.core.search.indexing.IndexManager$1.execute(IndexManager.java:984)
at org.eclipse.jdt.internal.core.search.processing.JobManager.run(JobManager.java:405)
at java.lang.Thread.run(Thread.java:745)**
Your Scala IDE Eclipse plug-in fails by using internal classes instead of public API from Eclipse (ClassCastException of org.eclipse.....internal.... classes in org.scalaide....). This could be caused by using an older version of the Scala plug-in in a newer version of Eclipse.
Either use the latest version of both, of Eclipse and of the Scala IDE plug-in or use the Scala IDE which contains Eclipse, Scala and the Scala plug-in of versions which have been tested together.
Related
I'm very new to Scala and I tried to run Scala project under Eclipse. I used sbt to create one, then ran sbteclipse to prepare it for Eclipse and imported it successfully. However when I try to run it I get
Error: Unable to initialize main class Main
Caused by: java.lang.NoClassDefFoundError: scala/Function0
error. Scala, sbt and Java are installed, because when I try to run the same project via console, using sbt, it works. What am I missing?
Thanks for any help!
It looks like the classpath of your Eclipse project is incomplete: it's missing the Scala library. Can you double check in Project Settings that the scala library is present?
If all you want to do is try a simple program, an simpler solution is to create a New Scala Project using the Eclipse wizard.
I am importing a Scala project after building it using sbt, in sbt library dependencies are json4s-native & json4s-jackson...
After building the project using sbt eclipse while importing it in Eclipse it gives following error:
Error in Scala compiler
java.lang.StackOverflowError
This screen comes:
& then this:
Scala version: 2.11.7
Log:
!ENTRY org.scala-ide.sdt.core 4 0 2017-09-08 12:42:02.495 !MESSAGE Error in Scala compiler
!STACK 0
java.lang.StackOverflowError
at scala.tools.nsc.typechecker.Typers$Typer.checkDead(Typers.scala:111)
at scala.tools.nsc.typechecker.Typers$Typer.typedSelectOrSuperCall$1(Typers.scala:4812)
at scala.tools.nsc.typechecker.Typers$Typer.typedInAnyMode$1(Typers.scala:5344)
Adding following parameter to eclipse.ini worked:
-Xss100m
This seems to be a Scala compiler bug (not Eclipse related):
Update Scala since some StackOverflowError bugs of the Scala compiler have already been fixed since version 2.11.7
If updating Scala does not help, you have to find out which code causes the error and how to avoid it (see open Scala StackOverflowError bugs).
In Eclipse Juno when I try to run Groovy source (that has a main method inside of it) I get:
Caught: java.lang.ExceptionInInitializerError
java.lang.ExceptionInInitializerError
Caused by: groovy.lang.GroovyRuntimeException: Conflicting module versions. Module [groovy-all is loaded in version 2.3.4 and you are trying to load version 2.3.3
Google, surprisingly, turned up nothing. When I go to Project >> Properties >> Groovy Compiler I see that my Groovy compiler is at 2.3, but it doesn't give me the option to select 2.3.3 or 2.3.4.
Any ideas what the fix is?
There is no fix for that. Each groovy-eclipse compiler is a version tweaked to work with eclipse JDT and whatnot. You can try to use other groovy-eclipse versions, which might feature the groovy version you need
I am using the newest version (2.8.0) of the Eclipse-Groovy plugin that ships with groovy-all-2.1.5.jar. I added Guice to my Groovy project, and when I go to run them from inside Eclipse I get the following error in the console output:
Caught: java.lang.NoClassDefFoundError: org/codehaus/groovy/runtime/typehandling/ShortTypeHandling
java.lang.NoClassDefFoundError: org/codehaus/groovy/runtime/typehandling/ShortTypeHandling
at net.me.myapp.utils.restclient.RestClient.<init>(RestClient.groovy:57)
at net.me.myapp.inject.UserServiceClientModule.configure(UserServiceClientModule.groovy:34)
at com.google.inject.AbstractModule.configure(AbstractModule.java:59)
at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:223)
at com.google.inject.spi.Elements.getElements(Elements.java:101)
at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:133)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:103)
at com.google.inject.Guice.createInjector(Guice.java:95)
at com.google.inject.Guice.createInjector(Guice.java:72)
at com.google.inject.Guice.createInjector(Guice.java:62)
at net.me.myapp.UserServiceClient.<init>(UserServiceClient.groovy:37)
at net.me.myapp.UserServiceClient.main(UserServiceClient.groovy:45)
Caused by: java.lang.ClassNotFoundException: org.codehaus.groovy.runtime.typehandling.ShortTypeHandling
... 12 more
According to this answer it's because ShortTypeHandling wasn't added until 2.3.x. So I would now like to attach groovy-all-2.3.3.jar to my Eclipse project's classpath.
The problem is that I don't seem to have edit permissions to change what library the Groovy Libraries library uses under the hood. And when I manually add the 2.3.3 JAR to my build path, I get the following error:
Caught: java.lang.ExceptionInInitializerError
java.lang.ExceptionInInitializerError
Caused by: groovy.lang.GroovyRuntimeException: Conflicting module versions. Module [groovy-all is loaded in version 2.1.5 and you are trying to load version 2.3.3
What are my options?
Groovy-eclipse versions have its own compilers and are "locked" to them. You may change the versions to whatever is listed under Window > Preferences > Groovy > Compilers, but, AFAIK, you can't change to an arbitrary version of the compiler by simply changing the groovy-all jar in the guts of the plugin dir.
You can install new compiler versions using the update site or eclipse marketplace
Update: install additional compiler versions through Help > Install new Software, select Groovy update site and expand the Extra Groovy Compilers session:
Note i'm using snapshot update site, because i like to live dangerously.
I add sbt eclipse plug-in .First I created the project named hello the in project directory i created a file named plugins.sbt and add this line in it
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.5.0")
and after the sbt> I typed eclipse then it created the project for eclipse
when I open eclipse it gives me error message
An error has occurred. See the error log for more details
The org.eclipse.jdt.ui.javaElementFilters plug-in extension "scala.tools.eclipse.javaelements.ScalaElementFilter" specifies a viewer filter class which does not exist.
Plug-in org.scala-ide.sdt.core was unable to load class scala.tools.eclipse.javaelements.ScalaElementFilter.
An error occurred while automatically activating bundle org.scala-ide.sdt.core (806).
please help me to how to resolve this error and when I imported the sbt project eclipse give me another error
Building workspace has encountered a problem
Errors occurred during the build.
Error instantiating builder 'org.scala-ide.sdt.core.scalabuilder'.
Plug-in org.scala-ide.sdt.core was unable to load class scala.tools.eclipse.ScalaBuilder.
An error occurred while automatically activating bundle org.scala-ide.sdt.core (806).
Plug-in org.scala-ide.sdt.core was unable to load class scala.tools.eclipse.ScalaBuilder.
An error occurred while automatically activating bundle org.scala-ide.sdt.core (806).
Please help me
scala version 2.11.1
sbt version 0.13
I added the scala-IDE plugin from this source
http://scala-ide.org/download/current.html
i am using eclipse juno and pasted the following location in install new software
http://download.scala-ide.org/sdk/helium/e38/scala211/stable/site
my project compiles successfully in sbt
Are you using Eclipse Luna for Java Developers (as opposed to Eclipse Classic) AND Scala IDE 4.0 milestone 3? There is a known issue (solved in the nightly builds since then), reported on the mailing list here.
You can "fix" it by either upgrading the Scala plugin to a nightly build (they're pretty stable), or going with Eclipse Classic instead.