geb/error/UnableToLoadException

已查看 674 次
跳至第一个未读帖子

Sean Lanter

未读,
2016年6月6日 19:32:432016/6/6
收件人 Geb User Mailing List
I have a 2-line script "example.groovy" that does nothing more than create a default Browser:

   import geb.Browser
   def browser = new Browser()

When I run it as follows:

   groovy -cp geb-core-0.13.1.jar:selenium-server-standalone-2.53.0.jar:.  example.groovy

this is what comes back:

   Caught: java.lang.NoClassDefFoundError: geb/error/UnableToLoadException
   java.lang.NoClassDefFoundError: geb/error/UnableToLoadException
       at geb.Browser.<init>(Browser.groovy:58)
       at example.run(example.groovy:2)

The script and the two jars file are all in the same directory.

I am certain I am missing something obvious...  Can someone point out what I am overlooking?

TIA!


Marcin Erdmann

未读,
2016年6月7日 03:11:212016/6/7
收件人 geb-...@googlegroups.com
You need more Geb modules in your classpath. If you're a masochist then you can have a look at the pom of geb-core and work out which dependencies it has, there might be some that are transitive. Otherwise use a build system to resolve your dependencies. I personally prefer Gradle but for the purpose of resolving deps Maven will do just fine. If this thing will never get serious and will stay a script forever then your third choice might be using Groovy's @Grab annotation(s).
--
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/94dcf964-a3a4-4443-81a2-e141a4b015ec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sean Lanter

未读,
2016年6月7日 11:16:182016/6/7
收件人 Geb User Mailing List
Well, masochism was fun for a while, but it looks like I simply need to learn Gradle :)

Thank you for your feedback, very much appreciated!



On Tuesday, June 7, 2016 at 12:11:21 AM UTC-7, Marcin Erdmann wrote:
You need more Geb modules in your classpath. If you're a masochist then you can have a look at the pom of geb-core and work out which dependencies it has, there might be some that are transitive. Otherwise use a build system to resolve your dependencies. I personally prefer Gradle but for the purpose of resolving deps Maven will do just fine. If this thing will never get serious and will stay a script forever then your third choice might be using Groovy's @Grab annotation(s).

On Tuesday, 7 June 2016, Sean Lanter <seanl...@gmail.com> wrote:
I have a 2-line script "example.groovy" that does nothing more than create a default Browser:

   import geb.Browser
   def browser = new Browser()

When I run it as follows:

   groovy -cp geb-core-0.13.1.jar:selenium-server-standalone-2.53.0.jar:.  example.groovy

this is what comes back:

   Caught: java.lang.NoClassDefFoundError: geb/error/UnableToLoadException
   java.lang.NoClassDefFoundError: geb/error/UnableToLoadException
       at geb.Browser.<init>(Browser.groovy:58)
       at example.run(example.groovy:2)

The script and the two jars file are all in the same directory.

I am certain I am missing something obvious...  Can someone point out what I am overlooking?

TIA!


--
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+unsubscribe@googlegroups.com.

Dan Schmitt

未读,
2016年9月26日 16:54:542016/9/26
收件人 Geb User Mailing List
So, if I wanted a command line web scraper with geb, and tried to use @Grab and got:

General error during conversion: Error grabbing Grapes -- [download failed: commons-io#commons-io;2.4!commons-io.jar]

but the https://github.com/geb/geb-example-gradle build works fine, that's likely some issue with Grab not supporting some special characters somewhere?


 

On Tuesday, June 7, 2016 at 3:11:21 AM UTC-4, Marcin Erdmann wrote:
You need more Geb modules in your classpath. If you're a masochist then you can have a look at the pom of geb-core and work out which dependencies it has, there might be some that are transitive. Otherwise use a build system to resolve your dependencies. I personally prefer Gradle but for the purpose of resolving deps Maven will do just fine. If this thing will never get serious and will stay a script forever then your third choice might be using Groovy's @Grab annotation(s).

On Tuesday, 7 June 2016, Sean Lanter <seanl...@gmail.com> wrote:
I have a 2-line script "example.groovy" that does nothing more than create a default Browser:

   import geb.Browser
   def browser = new Browser()

When I run it as follows:

   groovy -cp geb-core-0.13.1.jar:selenium-server-standalone-2.53.0.jar:.  example.groovy

this is what comes back:

   Caught: java.lang.NoClassDefFoundError: geb/error/UnableToLoadException
   java.lang.NoClassDefFoundError: geb/error/UnableToLoadException
       at geb.Browser.<init>(Browser.groovy:58)
       at example.run(example.groovy:2)

The script and the two jars file are all in the same directory.

I am certain I am missing something obvious...  Can someone point out what I am overlooking?

TIA!


--
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+unsubscribe@googlegroups.com.

Marcin Erdmann

未读,
2016年9月26日 17:17:542016/9/26
收件人 Geb User Mailing List
How did you get from the error you got to "Grab not supporting some special characters somewhere"?

Looks like it might simply be a connectivity issue. Did you try retrying?

Dan Schmitt

未读,
2016年9月26日 17:35:512016/9/26
收件人 Geb User Mailing List
I have tried a couple times.  My Android gradle stuff seems fine.
The geb-example-gradle ran (so I think it got everything.)

I'm pulling in the same module/versions with @Grab as I see in geb-example-gradle, so I guessed it was @Grab vs. whatever gradle does for dependencies { testCompile ... bla bla.)

My script starts with:

#!/bin/bash
//usr/bin/env groovy  -cp extra.jar:spring.jar:etc.jar -d -Dlog4j.configuration=file:/etc/myapp/log4j.xml "$0" $@; exit $?


@Grab(group='org.gebish',module='geb-spock', version='1.0-rc-1')
@Grab(group='org.seleniumhq.selenium',module='selenium-firefox-driver', version='2.51.0')
@Grab(group='org.seleniumhq.selenium',module='selenium-support', version='2.51.0')

import geb.Browser
import geb.Page

and those seem to match

ext {
    // The drivers we want to use
    drivers = ["firefox", "chrome", "phantomJs"]

    ext {
        groovyVersion = '2.4.5'
        gebVersion = '1.0-rc-1'
        seleniumVersion = '2.51.0'
        chromeDriverVersion = '2.19'
        phantomJsVersion = '1.9.7'
    }
}

.... more stuff from the working geb-example-gradle-master....

dependencies {
    // If using Spock, need to depend on geb-spock
    testCompile "org.gebish:geb-spock:$gebVersion"
    testCompile("org.spockframework:spock-core:1.0-groovy-2.4") {
        exclude group: "org.codehaus.groovy"
    }
    testCompile "org.codehaus.groovy:groovy-all:$groovyVersion"

    // If using JUnit, need to depend on geb-junit (3 or 4)
    testCompile "org.gebish:geb-junit4:$gebVersion"

    // Drivers
    testCompile "org.seleniumhq.selenium:selenium-chrome-driver:$seleniumVersion"
    testCompile "org.seleniumhq.selenium:selenium-firefox-driver:$seleniumVersion"

The only difference seems to be @Grab vs gradle's depend.   (Might not be a special character, the default @Grab config stuff might differ from the Gradle, don't know, but that was my guess.)  
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.

Dan Schmitt

未读,
2016年9月26日 17:39:372016/9/26
收件人 Geb User Mailing List
And further testing, it's just something with @Grab and the geb stuff (selenium and tagsoup load fine):


#!/bin/bash
//usr/bin/env groovy  -cp extra.jar:spring.jar:etc.jar -d -Dlog4j.configuration=file:/etc/myapp/log4j.xml "$0" $@; exit $?


// @Grab(group='org.gebish',module='geb-spock', version='1.0-rc-1')

@Grab(group='org.seleniumhq.selenium',module='selenium-firefox-driver', version='2.51.0')
@Grab(group='org.seleniumhq.selenium',module='selenium-support', version='2.51.0')

@Grab(group='org.ccil.cowan.tagsoup',
      module='tagsoup', version='1.2' )
def tagsoupParser = new org.ccil.cowan.tagsoup.Parser()
def slurper = new XmlSlurper(tagsoupParser)
def htmlParser = slurper.parse("http://stackoverflow.com/")

htmlParser.'**'.findAll{ it.@class == 'question-hyperlink'}.each {
    println it

Dan Schmitt

未读,
2016年9月26日 17:43:392016/9/26
收件人 Geb User Mailing List
And in other bonus news, something really odd is going on.  I blew away the .m2 and .groovy as suggested on
stackoverflow for @grab issues, and the message is now:

Caught: BUG! exception in phase 'conversion' in source unit '/Users/user1/torgo' # Licensed to the Apache Software Foundation (ASF) under one or more
BUG! exception in phase 'conversion' in source unit '/Users/user1/torgo' # Licensed to the Apache Software Foundation (ASF) under one or more

when @Grab includes geb....

Marcin Erdmann

未读,
2016年9月26日 17:45:242016/9/26
收件人 Geb User Mailing List
Oh, is it because Geb depends on Groovy and Groovy doesn't like other version pulled in using Grapes?
If that's it then you need to add @GrabExclude('org.codehaus.groovy:groovy-all').


--
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+unsubscribe@googlegroups.com.
To post to this group, send email to geb-...@googlegroups.com.

Dan Schmitt

未读,
2016年9月26日 17:51:252016/9/26
收件人 Geb User Mailing List
That was it.  For anybody wanting to do the script thing, this is what's working for me:


#!/bin/bash
//usr/bin/env groovy  -cp extra.jar:spring.jar:etc.jar -d -Dlog4j.configuration=file:/etc/myapp/log4j.xml "$0" $@; exit $?

@GrabExclude('org.codehaus.groovy:groovy-all')

@Grab(group='org.gebish',module='geb-spock', version='1.0-rc-1')
@Grab(group='org.seleniumhq.selenium',module='selenium-firefox-driver', version='2.51.0')
@Grab(group='org.seleniumhq.selenium',module='selenium-support', version='2.51.0')

import geb.Browser
import geb.Page
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.
回复全部
回复作者
转发
0 个新帖子