Search
Calendar
May 2017
S M T W T F S
« Sep    
 123456
78910111213
14151617181920
21222324252627
28293031  
Your widget title
Archives

Posts Tagged ‘Grab’

PostHeaderIcon Error grabbing Grapes — [unresolved dependency: com.oracle#ojdbc14;10.2.0.4.0: not found]

I have learnt Groovy since the beginning of the week.
I had to import some classes from Oracle JDBC driver. As a newbie, I wrote the following annotation:

@Grab(group = 'com.oracle', module = 'ojdbc14', version = '10.2.0.4.0')

I got the following error:

Error grabbing Grapes -- [unresolved dependency: com.oracle#ojdbc14;10.2.0.4.0: not found]

To sum up, adding a dependency to Oracle driver raises two issues:

  • adding any external dependency
  • adding a dependency to any JDBC driver

Indeed, Grab requires a kind of Maven repository, and you can catch the link between the @Grab annotation below and classic Maven 2 <dependency> tag. As I understood, Grab instructions are closer to Ivy than to Maven system. In my situation, having no “Grab repo” (I don’t know how to call that), I had to download the jars from a Maven repo. To fix it, two operations are needed: hint at Maven (or Ivy) repo, and allow Groovy to access the network.

Regarding the second issue, it is answered by added a @GrabConfig annotation.
Therefore, to fix the original issue:

  • replace
    @Grab(group = 'com.oracle', module = 'ojdbc14', version = '10.2.0.4.0')

    with

    @GrabConfig(systemClassLoader=true)
    @GrabResolver(name='nameOfYourMavenRepo, root='http://url-of-your-maven-repo:port')
    @Grab(group = 'com.oracle', module = 'ojdbc14', version = '10.2.0.4.0')
    
  • at first run, if needed, hint at the proxy to allow Grab to download the Jars, eg:
    groovy -Dhttp.proxyHost=myProxyHost -Dhttp.proxyPort=8080

You may notice the needed JAR will be written in the $USER_HOME/.groovy/grapes folder.