Groovy
  1. Groovy
  2. GROOVY-7613

Grape fails to load Groovy Extensions

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.5, 2.4.1, 2.4.4
    • Fix Version/s: 2.4.7
    • Component/s: Grape
    • Labels:
      None
    • Environment:
      OS X 10.10.5

      Description

      https://github.com/elastic/elasticsearch-groovy/issues/29

      The problem is that it has Groovy itself as a dependency, so using GrabExclude avoids the dependency and therefore the issue.

      A user of mine ran into an issue while trying to use Grape to load a recent version of the elasticsearch-groovy jar. I was able to reproduce in different versions of Groovy.

      @Grapes(
           @Grab(group='org.elasticsearch', module='elasticsearch-groovy', version='1.7.1')
      )
      import java.lang.String
      

      Literally that code when launched via:

      $ groovy file.groovy
      Caught: BUG! exception in phase 'conversion' in source unit '/Users/pickypg/Dev/es/es-groovy/tmp/elasticsearch.groovy' # Licensed to the Apache Software Foundation (ASF) under one or more
      BUG! exception in phase 'conversion' in source unit '/Users/pickypg/Dev/es/es-groovy/tmp/elasticsearch.groovy' # Licensed to the Apache Software Foundation (ASF) under one or more
      Caused by: java.lang.ClassNotFoundException: # Licensed to the Apache Software Foundation (ASF) under one or more
      

      Using this code:

      import groovy.grape.Grape
      
      try {
        Grape.grab(group: 'org.elasticsearch', module: 'elasticsearch-groovy', version: '1.7.1')
      }
      catch (Throwable t) {
        t.printStackTrace()
      }
      

      This creates a surprising stacktrace:

      java.lang.ClassNotFoundException: # Licensed to the Apache Software Foundation (ASF) under one or more
      	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
      	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
      	at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:677)
      	at groovy.lang.GroovyClassLoader$InnerLoader.loadClass(GroovyClassLoader.java:425)
      	at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:787)
      	at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:775)
      	at groovy.lang.GroovyClassLoader$loadClass.call(Unknown Source)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
      	at groovy.grape.GrapeIvy$_processRunners_closure4.doCall(GrapeIvy.groovy:340)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:497)
      	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
      	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
      	at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1019)
      	at groovy.lang.Closure.call(Closure.java:426)
      	at groovy.lang.Closure.call(Closure.java:442)
      	at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2030)
      	at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2015)
      	at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2056)
      	at org.codehaus.groovy.runtime.dgm$162.invoke(Unknown Source)
      	at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:274)
      	at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
      	at groovy.grape.GrapeIvy.processRunners(GrapeIvy.groovy:339)
      	at groovy.grape.GrapeIvy$processRunners$3.callCurrent(Unknown Source)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:182)
      	at groovy.grape.GrapeIvy.processOtherServices(GrapeIvy.groovy:324)
      	at groovy.grape.GrapeIvy$processOtherServices$2.callCurrent(Unknown Source)
      	at groovy.grape.GrapeIvy.grab(GrapeIvy.groovy:265)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:497)
      	at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSite.invoke(PogoMetaMethodSite.java:169)
      	at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:174)
      	at groovy.grape.GrapeIvy.grab(GrapeIvy.groovy:239)
      	at groovy.grape.Grape.grab(Grape.java:151)
      	at groovy.grape.Grape$grab.call(Unknown Source)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
      	at elasticsearch.run(elasticsearch.groovy:4)
      	at groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:263)
      	at groovy.lang.GroovyShell.run(GroovyShell.java:524)
      	at groovy.lang.GroovyShell.run(GroovyShell.java:513)
      	at groovy.ui.GroovyMain.processOnce(GroovyMain.java:652)
      	at groovy.ui.GroovyMain.run(GroovyMain.java:384)
      	at groovy.ui.GroovyMain.process(GroovyMain.java:370)
      	at groovy.ui.GroovyMain.processArgs(GroovyMain.java:129)
      	at groovy.ui.GroovyMain.main(GroovyMain.java:109)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:497)
      	at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:109)
      	at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:131)
      

        Issue Links

          Activity

          Hide
          Gerd Aschemann added a comment -

          Ran into the same problem and yes, an exclude solves it:

          @GrabExclude('org.codehaus.groovy:groovy-all')
          

          Nevertheless I would like to see the issue solved since I would not like to care about the transitive dependencies of a used artifact.

          Show
          Gerd Aschemann added a comment - Ran into the same problem and yes, an exclude solves it: @GrabExclude('org.codehaus.groovy:groovy-all') Nevertheless I would like to see the issue solved since I would not like to care about the transitive dependencies of a used artifact.
          Hide
          Paul King added a comment -

          I believe this was fixed as part of GROOVY-7833

          Show
          Paul King added a comment - I believe this was fixed as part of GROOVY-7833

            People

            • Assignee:
              Paul King
              Reporter:
              Chris Earle
            • Votes:
              2 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development