jrock2004
jrock2004

Reputation: 3501

Simple Groovy with Geb script

I am trying to learn Geb and on my Mac I created a groovy script and tried to run it. I getting errors about grapes not being able to download some dependencies. Do I need to do something special for this to work?

@Grab(group='org.codehaus.geb', module='geb-core', version='0.7.1')
@Grab(group='org.seleniumhq.selenium', module='selenium-firefox-driver', version='2.31.0')

import geb.*
import org.openqa.selenium.firefox.FirefoxDriver

Browser.drive(driver: new FirefoxDriver()) {
    go "http://ebay.com/"
    $('input#gh-ac').value("transformers")
    $('input#gh-btn').click()
    sleep 10000
}

Here is the error message I am getting.

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
General error during conversion: Error grabbing Grapes -- [download failed: org.apache.httpcomponents#httpclient;4.2.1!httpclient.jar, download failed: org.apache.httpcomponents#httpcore;4.2.1!httpcore.jar]

java.lang.RuntimeException: Error grabbing Grapes -- [download failed: org.apache.httpcomponents#httpclient;4.2.1!httpclient.jar, download failed: org.apache.httpcomponents#httpcore;4.2.1!httpcore.jar]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
    at org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:71)
    at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrap.callConstructor(ConstructorSite.java:81)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:57)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:182)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:190)
    at groovy.grape.GrapeIvy.getDependencies(GrapeIvy.groovy:411)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    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 groovy.grape.GrapeIvy.resolve(GrapeIvy.groovy:546)
    at groovy.grape.GrapeIvy$resolve$0.callCurrent(Unknown Source)
    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:153)
    at groovy.grape.GrapeIvy.resolve(GrapeIvy.groovy:515)
    at groovy.grape.GrapeIvy$resolve.callCurrent(Unknown Source)
    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:149)
    at groovy.grape.GrapeIvy.grab(GrapeIvy.groovy:254)
    at groovy.grape.Grape.grab(Grape.java:141)
    at groovy.grape.GrabAnnotationTransformation.visit(GrabAnnotationTransformation.java:312)
    at org.codehaus.groovy.transform.ASTTransformationVisitor$3.call(ASTTransformationVisitor.java:319)
    at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:912)
    at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:575)
    at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:551)
    at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:528)
    at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:279)
    at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:258)
    at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:244)
    at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:185)
    at groovy.lang.GroovyShell$2.run(GroovyShell.java:206)
    at groovy.lang.GroovyShell$2.run(GroovyShell.java:204)
    at java.security.AccessController.doPrivileged(Native Method)
    at groovy.lang.GroovyShell.run(GroovyShell.java:204)
    at groovy.lang.GroovyShell.run(GroovyShell.java:150)
    at groovy.ui.GroovyMain.processOnce(GroovyMain.java:588)
    at groovy.ui.GroovyMain.run(GroovyMain.java:375)
    at groovy.ui.GroovyMain.process(GroovyMain.java:361)
    at groovy.ui.GroovyMain.processArgs(GroovyMain.java:120)
    at groovy.ui.GroovyMain.main(GroovyMain.java:100)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:106)
    at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:128)

1 error

Thanks for any help.

Upvotes: 1

Views: 1848

Answers (2)

Sean Gilligan
Sean Gilligan

Reputation: 86

I had the same error as above -- problems downloading httpclient.

I commented the following line in my grapeConfig.xml and the problem was resolved:

<ibiblio name="local" root="file:${user.home}/.m2/repository/" m2compatible="true"/>

Interestingly, after successfully running the Geb script, I could re-enable the above line of XML and the script still runs. I'm guessing something was corrupted in the "local" .m2 repository.

Upvotes: 2

erdi
erdi

Reputation: 6954

Looks to me like it's an environment issue. I've just copypasted the code from your snippet to a groovy console and it worked without any problems. Are you behind some firewall that would prevent Ivy from connecting to Maven Central?

Upvotes: 0

Related Questions