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.
Related
I have installed Grails 2.5.5 in Eclipse GGTS (3.6.4.RELEASE) and have added Groovy Compiler feature 2.4.12. I am importing existing projects into the workspace.
Before updating the compiler, refresh dependencies (on a new project) worked without problems. Now, when I run Refresh Dependencies (alt+g,r), it throws an error. I am looking for guidance to help resolve the issue. The log shows the following
!ENTRY org.grails.ide.eclipse.core 4 0 2017-07-25 18:43:19.426
!MESSAGE Refresh dependecies failed
!STACK 0
java.lang.NoClassDefFoundError: org/codehaus/groovy/frameworkadapter/util/SpecifiedVersion
at org.grails.ide.eclipse.commands.GroovyCompilerVersionCheck.getRequiredGroovyVersion(GroovyCompilerVersionCheck.java:63)
at org.grails.ide.eclipse.commands.GroovyCompilerVersionCheck.getRequiredGroovyVersion(GroovyCompilerVersionCheck.java:57)
at org.grails.ide.eclipse.commands.GroovyCompilerVersionCheck.check(GroovyCompilerVersionCheck.java:50)
at org.grails.ide.eclipse.commands.GrailsCommandUtils.refreshDependencies(GrailsCommandUtils.java:327)
at org.grails.ide.eclipse.core.internal.classpath.GrailsClasspathContainerUpdateJob.runInWorkspace(GrailsClasspathContainerUpdateJob.java:89)
at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:38)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Background
This is an issue present in a specific version of the groovy-eclipse plugin. As far as I know the issue is present in groovy-eclipse v2.9.2.xx-201707260047-e44 (groovy compiler v2.4.12).
Since then the issue has ben reported and fixed.
Solution
To solve the problem simply update the groovy-eclipse plugin to v2.9.2.xx-201707311844-e44 or newer:
In the Help menu select Install New Software
Select or add the source http://dist.springsource.org/snapshot/GRECLIPSE/e4.4/ in the Work with field
In the Groovy Compilers category select the Groovy Compiler 2.4 item
Clic Next and proceed with the update
Restart GGTS to apply the changes
I am trying to follow the instructions at
https://confluence.jetbrains.com/display/SCA/Setting+up+Scala+plugin+project+in+IntelliJ+IDEA
I am using Idea 14.1.14.
Have downloaded the sources and downloadIdea.
And after importing the project set the Project SDK to 1.7.
Not sure if the above is enough info to go on; but on make project I get the below error; is it possible to guess at what I've got incorrect?
Error:scalac: error while loading Object, Missing dependency 'object scala in compiler mirror', required by /usr/lib/jvm/java-7-oracle/jre/lib/rt.jar(java/lang/Object.class)
Error:scalac: Error: object scala in compiler mirror not found.
scala.reflect.internal.MissingRequirementError: object scala in compiler mirror not found.
at scala.reflect.internal.MissingRequirementError$.signal(MissingRequirementError.scala:17)
at scala.reflect.internal.MissingRequirementError$.notFound(MissingRequirementError.scala:18)
at scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:53)
at scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:66)
at scala.reflect.internal.Mirrors$RootsBase.getPackage(Mirrors.scala:173)
at scala.reflect.internal.Definitions$DefinitionsClass.ScalaPackage$lzycompute(Definitions.scala:161)
at scala.reflect.internal.Definitions$DefinitionsClass.ScalaPackage(Definitions.scala:161)
at scala.reflect.internal.Definitions$DefinitionsClass.ScalaPackageClass$lzycompute(Definitions.scala:162)
at scala.reflect.internal.Definitions$DefinitionsClass.ScalaPackageClass(Definitions.scala:162)
at scala.reflect.internal.Definitions$DefinitionsClass.init(Definitions.scala:1377)
at scala.tools.nsc.Global$Run.<init>(Global.scala:1229)
at xsbt.CachedCompiler0$$anon$2.<init>(CompilerInterface.scala:116)
at xsbt.CachedCompiler0.run(CompilerInterface.scala:116)
at xsbt.CachedCompiler0.run(CompilerInterface.scala:102)
at xsbt.CompilerInterface.run(CompilerInterface.scala:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at sbt.compiler.AnalyzingCompiler.call(AnalyzingCompiler.scala:102)
at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:48)
at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:41)
at org.jetbrains.jps.incremental.scala.local.IdeaIncrementalCompiler.compile(IdeaIncrementalCompiler.scala:29)
at org.jetbrains.jps.incremental.scala.local.LocalServer.compile(LocalServer.scala:26)
at org.jetbrains.jps.incremental.scala.remote.Main$.make(Main.scala:62)
at org.jetbrains.jps.incremental.scala.remote.Main$.nailMain(Main.scala:20)
at org.jetbrains.jps.incremental.scala.remote.Main.nailMain(Main.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.martiansoftware.nailgun.NGSession.run(NGSession.java:319)
Warning:scalac: No 'scala-library*.jar' in module dependencies [compiler_settings]
Go to File -> Project structure -> Global libraries and add Scala SDK there. In my case, two SDKs were already present (in ivy folder) and offered for selection.
I have faced a similar issue recently even after having the compatible versions of java,sbt and scala SDK but found few reasons why we get this error when we importing sbt project into Intellij.
Check the scala-SDK is present in the global libraries under File->Project Structure -> Global Libraries.
Please find the below screenshot.
Even after fixing the first issue you still face this issue. Then look for the external dependencies which you have placed under /lib folder check the checksum of that jar if possible are make sure it has the right size. This should solve the issue.
Apart from the above issue, you might end up with dependencies source linking issues in the code when you open the project in IntelliJ. This is because of the additional root modules which are present under File -> Project modules -> modules. In the modules panel, you will see projectxxx-src and projectxx-test additional to projexctxx-process and projectxx-process-build. So remove the projectxx-src and projectxx-test.
You have to have Java 8 JDK for Scala to work
see the scala site for further info
Only Java 8 JDK version should be used along side scala. Not even higher JDK versions.
better also check here. It solved my own building errors
In my case, I had to specify the correct JDK home path in the Project structure -> SDKs.
Since my JAVA_HOME variable was not set yet, Intellij was taking a default value which doesn't exist.
Replace the JDK Home Path by the the right path of the JDK (in my case it was the following : /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home)
Replace 'adoptopenjdk-8.jdk' by your folders' name (might be jdk_1.8.0_xxx.jdk)
I hope it helps.
Double-Check JDK Compatibility
I encountered this issue when the Java SDK being used by my IntelliJ project was too "new" for the version of Scala I was using. For example, IntelliJ defaulted to using Java 12 for my project when my project was using Scala version 2.11.8. However, according to the documentation, the minimum required Scala version for JDK 11 is 2.11.12; therefore, I resolved this problem by changing the JDK used in IntelliJ to Java 8 by going to File -> Project Structure -> Project -> Project SDK
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 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.
I am running Windows 7. The following code works in Groovy Console:
def fileEx = new File(/Y:\Documents\Test File.txt/)
def copyToFile = new File(/Y:\Documents\Test File - Copied by Groovy and Ant.txt/)
ant = new AntBuilder()
ant.copy(file:fileEx, tofile:copyToFile)
but when I try to run it as a Groovy Script in Eclipse, I get this error:
Caught: java.lang.NoClassDefFoundError: org/apache/tools/ant/BuildException
java.lang.NoClassDefFoundError: org/apache/tools/ant/BuildException
at copyFile.run(copyFile.groovy:4)
Caused by: java.lang.ClassNotFoundException: org.apache.tools.ant.BuildException
I have tried adding ant.jar to myclasspath, both the ant.jar in the Groovy lib folder and the one in the Eclipse plugins lib folder, but this does not solve the problem.
Looks like groovy-eclipse plugin ships with a subset of libraries a full install of groovy does. You'll want a full install of groovy, which you may already have, in addition to the eclipse plugin.
You should be able to solve your problem by going to your project, and going to Properties->Java Build Path, then click 'Libraries'. 'Add External Jars' and navigate to your full groovy installation. Under there, the lib directory should have the ant.jar and ant-launcher.jar. Add them both. This should clear this up (and queue up the underlying problem for debugging).