Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-6306

Unable to use Grape to grab DLLs

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.5
    • Fix Version/s: 2.2.0-beta-2
    • Component/s: Grape
    • Labels:
      None

      Description

      As per GROOVY-4722, we should be able to use the "ext" or "type" attribute on the @Grab annotation to add a dependency on a DLL. Here's the sample code from GROOVY-4722:

      @Grab(group='net.sf.jacob-project', module='jacob', version='1.14.3')
      @Grab(group='net.sf.jacob-project', module='jacob', version='1.14.3', classifier='x64', type='dll')
      import groovy.grape.Grape
      println 'done'

      However, this is the stack trace I get:

      >groovy -d test.groovy
      Caught: java.lang.ExceptionInInitializerError
      java.lang.ExceptionInInitializerError
              at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
              at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
              at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
              at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
              at java.lang.Class.newInstance0(Class.java:372)
              at java.lang.Class.newInstance(Class.java:325)
              at groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:248)
              at groovy.lang.GroovyShell.run(GroovyShell.java:220)
              at groovy.lang.GroovyShell.run(GroovyShell.java:150)
              at groovy.ui.GroovyMain.processOnce(GroovyMain.java:557)
              at groovy.ui.GroovyMain.run(GroovyMain.java:344)
              at groovy.ui.GroovyMain.process(GroovyMain.java:330)
              at groovy.ui.GroovyMain.processArgs(GroovyMain.java:119)
              at groovy.ui.GroovyMain.main(GroovyMain.java:99)
              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:601)
              at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:106)
              at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:128)
      Caused by: java.util.zip.ZipException: error in opening zip file
              at java.util.zip.ZipFile.open(Native Method)
              at java.util.zip.ZipFile.<init>(ZipFile.java:214)
              at java.util.zip.ZipFile.<init>(ZipFile.java:144)
              at java.util.zip.ZipFile.<init>(ZipFile.java:158)
              at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
              at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
              at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
              at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
              at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
              at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:102)
              at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:190)
              at groovy.grape.GrapeIvy.processOtherServices(GrapeIvy.groovy:314)
              at groovy.grape.GrapeIvy$processOtherServices.callCurrent(Unknown Source)
              at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
              at groovy.grape.GrapeIvy$processOtherServices.callCurrent(Unknown Source)
              at groovy.grape.GrapeIvy.grab(GrapeIvy.groovy:258)
              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:601)
              at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSite.invoke(PogoMetaMethodSite.java:231)
              at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:52)
              at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
              at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
              at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:145)
              at groovy.grape.GrapeIvy.grab(GrapeIvy.groovy:236)
              at groovy.grape.Grape.grab(Grape.java:129)
              at groovy.grape.Grape$grab.callStatic(Unknown Source)
              at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:53)
              at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:157)
              at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:165)
              at test.<clinit>(test.groovy)
              ... 20 more

      I'm using Groovy 2.0.5, and the line numbers have changed a bit in master, but the bug still exists here:

      https://github.com/groovy/groovy-core/blob/master/src/main/groovy/grape/GrapeIvy.groovy

      for (URI uri in uris) {
          //TODO check artifact type, jar vs library, etc
          File file = new File(uri)
          processCategoryMethods(loader, file)
          processOtherServices(loader, file)
      }

      The processCategoryMethods() method checks that the file is a JAR before doing its magic, but the processOtherServices() method just assumes that the file provided is a Zip file.

        Attachments

          Activity

            People

            • Assignee:
              paulk Paul King
              Reporter:
              sdanig Daniel Gredler
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: