Ошибка связи с geb

Я пытаюсь просто попробовать базовый скрипт geb, к сожалению, у меня, похоже, серьезные проблемы с запуском этого.

Я использую IntelliJ, я скачал банку geb-core с http://mvnrepository.com/artifact/org.gebish/geb-core/0.9.1, а также 4 его зависимости. Я добавил их в свой проект IntelliJ в структуре проекта в качестве зависимостей, когда я запускаю свой базовый скрипт.

import geb.Browser

Browser.drive {
    go "http://google.com/ncr"
}

Я получаю очень неприятную ошибку

Caught: java.lang.LinkageError: loader constraint violation in interface itable initialization: when resolving method "com.gargoylesoftware.htmlunit.html.DomNode.getAttributes()Lorg/w3c/dom/NamedNodeMap;" the class loader (instance of org/codehaus/groovy/tools/RootLoader) of the current class, com/gargoylesoftware/htmlunit/html/DomNode, and the class loader (instance of <bootloader>) for interface org/w3c/dom/Node have different Class objects for the type org/w3c/dom/NamedNodeMap used in the signature
java.lang.LinkageError: loader constraint violation in interface itable initialization: when resolving method "com.gargoylesoftware.htmlunit.html.DomNode.getAttributes()Lorg/w3c/dom/NamedNodeMap;" the class loader (instance of org/codehaus/groovy/tools/RootLoader) of the current class, com/gargoylesoftware/htmlunit/html/DomNode, and the class loader (instance of <bootloader>) for interface org/w3c/dom/Node have different Class objects for the type org/w3c/dom/NamedNodeMap used in the signature
    at com.gargoylesoftware.htmlunit.html.HTMLParser.parseHtml(HTMLParser.java:190)
    at com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultPageCreator.java:268)
    at com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageCreator.java:156)
    at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:455)
    at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:329)
    at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:394)
    at org.openqa.selenium.htmlunit.HtmlUnitDriver.get(HtmlUnitDriver.java:474)
    at org.openqa.selenium.htmlunit.HtmlUnitDriver.get(HtmlUnitDriver.java:452)
    at org.openqa.selenium.htmlunit.HtmlUnitDriver.<init>(HtmlUnitDriver.java:181)
    at org.openqa.selenium.htmlunit.HtmlUnitDriver.<init>(HtmlUnitDriver.java:191)
    at org.openqa.selenium.htmlunit.HtmlUnitDriver.<init>(HtmlUnitDriver.java:187)
    at geb.driver.NameBasedDriverFactory.getDriver(NameBasedDriverFactory.groovy:42)
    at geb.driver.CachingDriverFactory$_getDriver_closure3.doCall(CachingDriverFactory.groovy:80)
    at geb.driver.CachingDriverFactory$_getDriver_closure3.doCall(CachingDriverFactory.groovy)
    at geb.driver.CachingDriverFactory$SimpleCache.get(CachingDriverFactory.groovy:30)
    at geb.driver.CachingDriverFactory.getDriver(CachingDriverFactory.groovy:79)
    at geb.Configuration.createDriver(Configuration.groovy:354)
    at geb.Configuration.getDriver(Configuration.groovy:343)
    at geb.Browser.getDriver(Browser.groovy:105)
    at geb.Browser.go(Browser.groovy:394)
    at geb.Browser$go$1.callCurrent(Unknown Source)
    at geb.Browser.go(Browser.groovy:386)
    at gebtest$_run_closure1.doCall(gebtest.groovy:14)
    at gebtest$_run_closure1.doCall(gebtest.groovy)
    at geb.Browser.drive(Browser.groovy:860)
    at geb.Browser$drive$0.callStatic(Unknown Source)
    at geb.Browser.drive(Browser.groovy:830)
    at geb.Browser$drive.call(Unknown Source)
    at gebtest.run(gebtest.groovy:13)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)

person dkirlin    schedule 04.06.2014    source источник
comment
Это выглядит как дубликат stackoverflow.com/questions/23545290/. У меня то же самое. Был один в jdk и один в xml-apis-1.4.01.jar, загруженный из htmlunit.   -  person Interlated    schedule 05.06.2014
comment
Да похожая проблема   -  person dkirlin    schedule 05.06.2014
comment
Я добавил xml-apis-1.4.01.jar в одобренный каталог. Затем я получаю, что SAXParserFactoryImpl не найден. Собираюсь заняться чем-то другим.   -  person Interlated    schedule 06.06.2014


Ответы (1)


Я бы предложил использовать Gradle, который избавит вас от ручной настройки проекта и разрешения зависимостей Geb. Самый простой способ сделать это с помощью gradle:

Установите инструмент GVM: http://gvmtool.net/

Установите Gradle через gvm: gvm install gradle 1.12

Создайте файл build.gradle:

apply plugin: 'idea'
apply plugin: 'groovy'

repositories {
    mavenCentral()
}

dependencies {
    compile 'org.gebish:geb-core:0.9.3'
    compile 'org.codehaus.groovy:groovy-all:2.3.3'
    compile 'org.seleniumhq.selenium:selenium-firefox-driver:2.42.2'
}

Создайте каталог src/main/groovy.

Выполнить gradle idea.

Откройте сгенерированный файл проекта идеи.

Поместите свой скрипт Geb в каталог src/main/groovy и запустите его.

person erdi    schedule 12.06.2014