Selecting exact Groovy version in Eclipse Juno - eclipse

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

Related

Grails 2.5.5 in Eclipse with Groovy Compiler 2.4.12 throws Refresh Dependencies error

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

Security Exception While Running TestNG test in Eclipse

Getting the below error while trying to run the TestNG test in Eclipse Neon . Seems like there is some sort signed content in jar dependency which is blocking this . have no idea what its though ..Any suggestions on how to fix this . Have never faced this before .
java.lang.SecurityException: Invalid signature file digest for Manifest main attributes
at sun.security.util.SignatureFileVerifier.processImpl(SignatureFileVerifier.java:284)
at sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier.java:238)
at java.util.jar.JarVerifier.processEntry(JarVerifier.java:273)
at java.util.jar.JarVerifier.update(JarVerifier.java:228)
at java.util.jar.JarFile.initializeVerifier(JarFile.java:383)
at java.util.jar.JarFile.getInputStream(JarFile.java:450)
at sun.net.www.protocol.jar.JarURLConnection.getInputStream(JarURLConnection.java:162)
at java.net.URL.openStream(URL.java:1045)
at org.testng.remote.RemoteTestNG.getTestNGVersion(RemoteTestNG.java:84)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:39)
[ServiceLoaderHelper] More than one working implementation for 'null', we will use the first one
Exception in thread "main" java.lang.NoSuchMethodError: org.testng.internal.Utils.defaultIfStringEmpty(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
at org.testng.remote.AbstractRemoteTestNG.setHost(AbstractRemoteTestNG.java:59)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:122)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:58)
oh, I sort of got your problem, looks like you're using an pretty old version of testng (probably the 5.x), since TestNG eclipse plugin 6.9.12.201607091356, TestNG versions below 6.5.1 are not supported: https://github.com/cbeust/testng-eclipse/blob/master/CHANGES.md#6910
So please upgrade your testng version.
Edit: since TestNG Eclipse Plugin 6.9.13.201609291640, the whole TestNG 6.x series are supported (including 6.0 to 6.5.1), while the TestNG 5.x still not be supported.

How to change Eclipse-Groovy plugin Groovy libraries?

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.

Drools Java 7 support in Eclipse

I created a Drools project in Eclipse (Indigo) configured to use JRE 1.7. But I get an error pointing to my .drl file:
com/sample/DroolsTest$Message : Unsupported major.minor version 51.0
The com.sample.DroolsTest.Message class is imported by the .drl file. The Drools runtime was 5.2.1 (also tried with 5.3.0.Final).
Any help would be appreciated. Thanks.
This exception doesn't seem to have to do anything with Drools in particular, but is a generic Java error. It occurs if you try to execute a Java class with a JRE that is older than the JDK that was used to compile it. For example, if you compiled the class with a JDK7 and then tried to execute it with a JDK6, you would get this error.
Just to detail above answer and comment. I had both JRE6 and JRE7 installed, with JRE7 being the default. I had to do two things to remove the error from the drools sample project.
Set the JRE for the project to 1.6
Project properties->Java Build Path->Libraries. Remove JRE System Library 1.7 and Add Library->JRE System Library->Alternate JRE->JRE6
Set the compiler compliance level for the project at 1.6.
Project properties->Java Compiler->check Enable Project specific settings and set Compiler compliance level at 1.6.

Using AspectJ/AJDT in RAD 7.5.5

I'm using RAD 7.5.5. I installed AJDT plugin from the download site:
http://archive.eclipse.org/tools/ajdt/34/update/
I converted one of the existing Java projects to an AspectJ project, added an aspect to print log statements on method start and end of a methodA(), rebuilt the project and deployed.
I'm getting the below exception when methodA() is called:
Exception thrown : java.lang.NoSuchMethodError: org/aspectj/runtime/reflect/Factory.makeMethodSig(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lorg/aspectj/lang/reflect/MethodSignature;
I googled and found this could be caused because of an older version of aspectjrt.jar. But RAD extends Eclipse 3.4 and hence I added the version of AJDT plugin that is compatible with Eclipse 3.4 (/RAD 7.5.5). Any pointers to what could be the problem?
Make sure that aspectjrt.jar is on your classpath. Also, make sure that it is the aspectjrt.jar that comes with AJDT.