Dee
Dee

Reputation: 233

"Exception in thread "main" java.lang.ClassNotFoundException: org.codehaus.groovy.tools.GroovyStarter" error while running a simple GEB program

I have:

and all the required jars.

I am trying to run a simple GEB program:

@Grapes([
    @Grab("org.codehaus.geb:geb-core:0.7.2"),    
    @Grab("org.seleniumhq.selenium:selenium-firefox-driver:2.28.0"),
    @Grab("org.seleniumhq.selenium:selenium-support:2.15.0")
])
import geb.Browser

Browser.drive {
    go "http://googel.com/"
    assert title == "Google"
}

and as I run this I am seeing the above mentioned exception:

Exception in thread "main" java.lang.ClassNotFoundException: org.codehaus.groovy.tools.GroovyStarter
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:169)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:113)

Upvotes: 1

Views: 9655

Answers (3)

Sanjay Bharwani
Sanjay Bharwani

Reputation: 4739

Basically your GROOVY_HOME is either pointing to wrong location or not accessible. Just correct it and job done.

I faced this when I was trying to execute a groovy script as part of some migration activity. The problem was simple. In my case it was not able to see the path of groovy installation. When I used full path of $GROOVY_HOME/bin/groovy <script> It worked.

Upvotes: 3

erdi
erdi

Reputation: 6954

It has nothing to do with Geb -- your environment is misconfigured.

Have a look at this groovy user mailing list thread.

Another thing is that as far as I know Geb 0.7.2 is compiled with Groovy 1.8.6 and I don't know if it's compatible with Groovy 2.0.

Upvotes: 1

Satya Kaveti
Satya Kaveti

Reputation: 354

Download Groovy Binary From http://groovy.codehaus.org/Download

Download zip: Binary Release

Extract Local Disk say D;\GROOVY\ groovy-2.3.9

It contains the Folder Structure D:. ├───bin ├───conf ├───embeddable ├───indy ├───lib └───META-INF

Go to Control Panel\User Accounts\User Accounts  Change My Environment Variables

Set/new GROOVY_HOME = D:\GROOVY\groovy-2.3.9 (don’t put : semicolon)

Set PATH = C:\Program Files\Java\jdk1.8.0_25\bin;%GROOVY_HOME%\bin;

Add groovy-all.jar to CLASSPATH

D:\ GROOVY\ \groovy-2.3.9\embeddable\groovy-all-2.3.9.jar;.

Close and Open Command and Say –groovy

For console -groovyConsole

Upvotes: 0

Related Questions