BUG! exception in phase 'conversion' in source unit

1,739 views
Skip to first unread message

Michael M

unread,
Feb 14, 2016, 5:56:42 AM2/14/16
to Geb User Mailing List
I'm taking my first steps in Geb, using the documentation as a guideline. And not making much progress (I am using Groovy 2.4.5).

The first attempt was to run this script, which we could maybe consider to be the "hello world" script for Geb:

@Grapes([
    @Grab("org.gebish:geb-core:0.13.0"),
    @Grab("org.seleniumhq.selenium:selenium-firefox-driver:2.50.1"),
    @Grab("org.seleniumhq.selenium:selenium-support:2.50.1")
])
import geb.Browser
Browser.drive {

    assert title == "Geb - Very Groovy Browser Automation" 

    $("#sidebar .sidemenu a", text: "jQuery-like API").click()

    assert $("#main h1")*.text() == ["Navigating Content", "Form Control Shortcuts"] 
    assert $("#sidebar .sidemenu a", text: "jQuery-like API").parent().hasClass("selected")
}

This results in:
Caught: BUG! exception in phase 'conversion' in source unit

A little googling led me to this bug:  https://issues.apache.org/jira/browse/GROOVY-7613

So I modified the script with the workaround suggested in the bug:

@Grapes([
    @Grab("org.gebish:geb-core:0.13.0"),
    @Grab("org.seleniumhq.selenium:selenium-firefox-driver:2.50.1"),
    @Grab("org.seleniumhq.selenium:selenium-support:2.50.1"),
    @GrabExclude('org.codehaus.groovy:groovy-all') // https://issues.apache.org/jira/browse/GROOVY-7613
])
import geb.Browser
Browser.drive {

    assert title == "Geb - Very Groovy Browser Automation" 

    $("#sidebar .sidemenu a", text: "jQuery-like API").click()

    assert $("#main h1")*.text() == ["Navigating Content", "Form Control Shortcuts"] 
    assert $("#sidebar .sidemenu a", text: "jQuery-like API").parent().hasClass("selected")
}

Result:

Caught: java.lang.NoSuchFieldError: INSTANCE
java.lang.NoSuchFieldError: INSTANCE
        at org.apache.http.conn.ssl.SSLConnectionSocketFactory.<clinit>(SSLConnectionSocketFactory.java:144)
        at org.openqa.selenium.remote.internal.HttpClientFactory.getClientConnectionManager(HttpClientFactory.java:71)
        at org.openqa.selenium.remote.internal.HttpClientFactory.<init>(HttpClientFactory.java:57)
        at org.openqa.selenium.remote.internal.HttpClientFactory.<init>(HttpClientFactory.java:60)
        at org.openqa.selenium.remote.internal.ApacheHttpClient$Factory.getDefaultHttpClientFactory(ApacheHttpClient.java:251)
        at org.openqa.selenium.remote.internal.ApacheHttpClient$Factory.<init>(ApacheHttpClient.java:228)
        at org.openqa.selenium.remote.HttpCommandExecutor.getDefaultClientFactory(HttpCommandExecutor.java:96)
        at org.openqa.selenium.remote.HttpCommandExecutor.<init>(HttpCommandExecutor.java:70)
        at org.openqa.selenium.remote.HttpCommandExecutor.<init>(HttpCommandExecutor.java:58)
        at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:97)
        at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:271)
        at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:119)
        at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:216)
        at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:211)
        at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:207)
        at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:120)
        at geb.driver.NameBasedDriverFactory.getDriver(NameBasedDriverFactory.groovy:44)
        at geb.driver.CachingDriverFactory$_getDriver_closure3.doCall(CachingDriverFactory.groovy:85)
        at geb.driver.CachingDriverFactory$_getDriver_closure3.doCall(CachingDriverFactory.groovy)
        at geb.driver.CachingDriverFactory$SimpleCache.get(CachingDriverFactory.groovy:32)
        at geb.driver.CachingDriverFactory.getDriver(CachingDriverFactory.groovy:84)
        at geb.Configuration.createDriver(Configuration.groovy:382)
        at geb.Configuration.getDriver(Configuration.groovy:371)
        at geb.Browser.getDriver(Browser.groovy:108)
        at geb.Browser.go(Browser.groovy:498)
        at geb.Browser$go$1.callCurrent(Unknown Source)
        at geb.Browser.go(Browser.groovy:488)
        at t1$_run_closure1.doCall(t1.groovy:9)
        at t1$_run_closure1.doCall(t1.groovy)
        at geb.Browser.drive(Browser.groovy:1061)
        at geb.Browser$drive$0.callStatic(Unknown Source)
        at geb.Browser.drive(Browser.groovy:1031)
        at geb.Browser$drive.call(Unknown Source)
        at t1.run(t1.groovy:8)


But now I'm stuck. Any help is appreciated.

Thanks,
Michael

Marcin Erdmann

unread,
Feb 16, 2016, 5:25:25 PM2/16/16
to Geb User Mailing List
Hi Michael,

I was able to successfully run the second snippet you provided (the one with @GrabExeclude) by putting it into a geb.groovy file and running "groovy geb.groovy" on the command line with Groovy 2.4.5 installed on my machine.

The stacktrace you provided looks like there might be multiple versions of Apache HttpClient on the classpath (I've seen similar errors where there was a problem with some of the Apache HttpClient class initalization when multiple versions somehow made it onto the classpath). I've also put the same dependencies into a a test Gradle project and run dependency report on them but there is only a single verison of HttpClient being referenced and there is no conflict resolution going on. This is very puzzling to be honest.

The only suggestion I would have is to use a build system (namely Gradle) instead of @Grab to resolve your dependencies. I described how to do it some time ago int this stackoverflow answer: http://stackoverflow.com/a/24195114/1856764. Note that you will want to replace the dependency versions I used in the snippet with the ones you used and remove @Grapes annotation from your script before dropping it into the Gradle project and running it using IntelliJ.

Marcin

--
You received this message because you are subscribed to the Google Groups "Geb User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geb-user+u...@googlegroups.com.
To post to this group, send email to geb-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geb-user/bac12a1e-db92-4077-8480-af07edeab139%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michael M

unread,
Feb 21, 2016, 6:29:12 AM2/21/16
to Geb User Mailing List
Thanks Marcin,

The problem was indeed that I had an HttpClient jar in my .lib folder.
Reply all
Reply to author
Forward
0 new messages