16

I have recently downloaded Eclipse Juno and installed latest Groovy plugin.

Now here is how my Groovy file looks like.

package groovy_support

class TimePass {
static void main(def args){
    println "Hello World"
}
}

When i run this from either my previous eclipse version (indigo) or from command line, it runs. On Eclipse Juno, however, it complains with following exception on Eclipse console.

Caught: java.lang.IncompatibleClassChangeError: Found class org.objectweb.asm.ClassVisitor, but interface was expected
java.lang.IncompatibleClassChangeError: Found class org.objectweb.asm.ClassVisitor, but interface was expected

Note that "Groovy Libraries" are already on classpath.

Now what am i doing wrong here?

Ajay George
  • 11,759
  • 1
  • 40
  • 48
user898535
  • 207
  • 1
  • 2
  • 9
  • What version of groovy are you using? Are you making sure that the version of groovy you are compiling with is the same as the version you are running it? – Andrew Eisenberg Jul 31 '12 at 17:54
  • I am using groovy 2.0.1 on the command line. In Eclipse Juno, my plugin shows groovy-all-2.0 and asm 4.0. In Eclipse Indigo, my plugin shows same. :) – user898535 Aug 01 '12 at 12:20
  • My guess is that you are compiling with an earlier version of groovy, but running with a later version. What version do you see when you go to Preferences -> Groovy -> Compiler? – Andrew Eisenberg Aug 02 '12 at 04:01
  • You may as well accept Ajay's answer below since his suggestion tipped me towards the likely problem that you were seeing. – Andrew Eisenberg Aug 02 '12 at 15:51

3 Answers3

18

Are you on the latest groovy/dependent jars? .

The java.lang.IncompatibleClassChangeError happens due to back ward compatibility issues. The client code needs to be recompiled to resolve it.

The specific error you are seeing is because org.objectweb.asm.ClassVisitor is an Interface in asm 3.2 and a Class in asm 4.0 onwards.

Ajay George
  • 11,759
  • 1
  • 40
  • 48
  • i am getting the same error not in my local machine when i do build it on jenkins. i excluded asm 3.2 from my POM but still get that error when jenkins tries to run the maven compiler once it finishes running the integration tests. – Venki Aug 31 '12 at 14:55
  • Thats correct Ajay. As mentioned before, that indeed seemed to be the problem. :) And it worked as per the suggestion. Thanks. :) – user898535 Dec 18 '12 at 10:17
  • Great. Consider accepting the answer by clicking on the tick button near the answer – Ajay George Dec 18 '12 at 10:43
2

I had the same problem using Spring and Groovy in one module. Spring in 3.1.2 still uses older ASM, Groovy uses the one with the class. While it may be possible to adjust some excludes, I bet it's not always an option.

After reading this thread I decided to do with groovy-all.jar instead of the list of all the Groovy needed libs. If that is an option for you, it might be easy way how to avoid any further problems.

virgo47
  • 2,283
  • 24
  • 30
0

I have tried many solutions for the below error. java.lang.IncompatibleClassChangeError: Found interface org.objectweb.asm.MethodVisitor, but class was expected. Only the one worked is exclude the groovy artifact from restassured dependency. Please refer to the below link for the complete workaround.

https://blog.jayway.com/2013/04/12/solving-asm-conflicts-after-upgrading-to-groovy-2-1/

S.Roshanth
  • 1,499
  • 3
  • 25
  • 36