Quantcast

problem running http-builder code

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

problem running http-builder code

frank.covert
I am new to groovy and trying to run this code from - http://groovy.codehaus.org/modules/http-builder/doc/index.html

import groovyx.net.http.HTTPBuilder
import static groovyx.net.http.Method.GET
import static groovyx.net.http.ContentType.TEXT
 
def http = new HTTPBuilder('http://www.google.com')
 
http.get( path : '/search',
          contentType : TEXT,
          query : [q:'Groovy'] ) { resp, reader ->
           
  println "response status: ${resp.statusLine}"
  println 'Headers: -----------'
  resp.headers.each { h ->
    println " ${h.name} : ${h.value}"
  }
  println 'Response data: -----'
  System.out << reader
  println '\n--------------------'
}

---------------
when I run this code in the terminal I get the following error:

:>groovy http-get.groovy 
Caught: java.lang.NoClassDefFoundError: org/apache/http/client/HttpResponseException
at http-get.class$(http-get.groovy)
at http-get.$get$$class$groovyx$net$http$HTTPBuilder(http-get.groovy)
at http-get.run(http-get.groovy:5)

I downloaded the http-builder.jar and copied into ~/.groovy/lib/ but It still doesn't work. Am I missing something?

Any help will be very appreciated.

--
Thanks & Regards,
Frank Covert
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: problem running http-builder code

Thom Nichols
Hi Frank,

HTTPBuilder has a number of dependencies that you can see from looking at the POM file here:
http://svn.codehaus.org/gmod/httpbuilder/trunk/pom.xml

If you download one of the 'all' packages:
http://snapshots.repository.codehaus.org/org/codehaus/groovy/modules/http-builder/http-builder/0.5.2-SNAPSHOT/
it contains all of the dependencies that you can drop into your .groovy/lib folder when you unpack it. 

You can also use @Grab annotation in your code as described here under the section "Using Grape":
http://groovy.codehaus.org/modules/http-builder/download.html
which will automatically download all necessary dependencies.

-Thom


On Fri, Mar 18, 2011 at 7:56 PM, Frank Covert <[hidden email]> wrote:
I am new to groovy and trying to run this code from - http://groovy.codehaus.org/modules/http-builder/doc/index.html

import groovyx.net.http.HTTPBuilder
import static groovyx.net.http.Method.GET
import static groovyx.net.http.ContentType.TEXT
 
def http = new HTTPBuilder('http://www.google.com')
 
http.get( path : '/search',
          contentType : TEXT,
          query : [q:'Groovy'] ) { resp, reader ->
           
  println "response status: ${resp.statusLine}"
  println 'Headers: -----------'
  resp.headers.each { h ->
    println " ${h.name} : ${h.value}"
  }
  println 'Response data: -----'
  System.out << reader
  println '\n--------------------'
}

---------------
when I run this code in the terminal I get the following error:

:>groovy http-get.groovy 
Caught: java.lang.NoClassDefFoundError: org/apache/http/client/HttpResponseException
at http-get.class$(http-get.groovy)
at http-get.$get$$class$groovyx$net$http$HTTPBuilder(http-get.groovy)
at http-get.run(http-get.groovy:5)

I downloaded the http-builder.jar and copied into ~/.groovy/lib/ but It still doesn't work. Am I missing something?

Any help will be very appreciated.

--
Thanks & Regards,
Frank Covert

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: problem running http-builder code

yuri2976
I followed all instructions, downloaded the all jar, added it to my build path and I am still getting
Caught: java.lang.NoClassDefFoundError: org/apache/http/client/methods/HttpRequestBase

Where the apache packages come from anyway?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: problem running http-builder code

yuri2976
I googled the missing jar, downloaded and added it to Build Path. Then groovy complained about an another missing class, I downloaded it and the process continued ad nauseum.

Is there a better way than to do all this manually?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: problem running http-builder code

Thom Nichols
Hi Yuri,

All of the dependencies can be found in either of these archives:
http://snapshots.repository.codehaus.org/org/codehaus/groovy/modules/http-builder/http-builder/0.5.2-SNAPSHOT/http-builder-0.5.2-20110320.041601-11-all.tar.gz
http://snapshots.repository.codehaus.org/org/codehaus/groovy/modules/http-builder/http-builder/0.5.2-SNAPSHOT/http-builder-0.5.2-20110320.041601-11-all.zip

If you're not using version 0.5.2-SNAPSHOT of httpbuilder, you can find your appropriate version here:
http://snapshots.repository.codehaus.org/org/codehaus/groovy/modules/http-builder/http-builder/
or here:
http://repository.codehaus.org/org/codehaus/groovy/modules/http-builder/http-builder/


On Fri, May 6, 2011 at 3:52 PM, yuri2976 <[hidden email]> wrote:
I googled the missing jar, downloaded and added it to Build Path. Then groovy
complained about an another missing class, I downloaded it and the process
continued ad nauseum.

Is there a better way than to do all this manually?

--
View this message in context: http://groovy.329449.n5.nabble.com/problem-running-http-builder-code-tp3995735p4376962.html
Sent from the groovy - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: problem running http-builder code

yuri2976
Tom,

Thank you for prompt reply.

My mistake was that I did not include the jars in the depencencies folder.

Is there an Eclipse update site fro this? It is odd to have to maintain all these jars as external jars.


----- Original Message -----
From: "Tom Nichols [via Groovy]" <[hidden email]>
To: "yuri2976" <[hidden email]>
Sent: Friday, May 6, 2011 1:02:48 PM
Subject: Re: problem running http-builder code

Hi Yuri,

All of the dependencies can be found in either of these archives:
http://snapshots.repository.codehaus.org/org/codehaus/groovy/modules/http-builder/http-builder/0.5.2-SNAPSHOT/http-builder-0.5.2-20110320.041601-11-all.tar.gz
http://snapshots.repository.codehaus.org/org/codehaus/groovy/modules/http-builder/http-builder/0.5.2-SNAPSHOT/http-builder-0.5.2-20110320.041601-11-all.zip

If you're not using version 0.5.2-SNAPSHOT of httpbuilder, you can find your appropriate version here:
http://snapshots.repository.codehaus.org/org/codehaus/groovy/modules/http-builder/http-builder/
or here:
http://repository.codehaus.org/org/codehaus/groovy/modules/http-builder/http-builder/


On Fri, May 6, 2011 at 3:52 PM, yuri2976 <[hidden email]> wrote:
I googled the missing jar, downloaded and added it to Build Path. Then groovy
complained about an another missing class, I downloaded it and the process
continued ad nauseum.

Is there a better way than to do all this manually?

--
View this message in context: http://groovy.329449.n5.nabble.com/problem-running-http-builder-code-tp3995735p4376962.html
Sent from the groovy - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email






If you reply to this email, your message will be added to the discussion below:
http://groovy.329449.n5.nabble.com/problem-running-http-builder-code-tp3995735p4376995.html
To unsubscribe from problem running http-builder code, click here.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: problem running http-builder code

Thom Nichols
Yuri,

I think Eclipse update sites are only for Eclipse plugins.  If you're not using Maven or Ivy to manage your dependencies, I think you'd typically have a 'lib' folder in your project where all of your external JARs get dropped, then it's easy to add all of these to your build path in Eclipse.

-Thom


On Fri, May 6, 2011 at 4:16 PM, yuri2976 <[hidden email]> wrote:
Tom,

Thank you for prompt reply.

My mistake was that I did not include the jars in the depencencies folder.

Is there an Eclipse update site fro this? It is odd to have to maintain all these jars as external jars.



----- Original Message -----
From: "Tom Nichols [via Groovy]" <[hidden email]>
To: "yuri2976" <[hidden email]>
Sent: Friday, May 6, 2011 1:02:48 PM
Subject: Re: problem running http-builder code

Hi Yuri,

All of the dependencies can be found in either of these archives:
http://snapshots.repository.codehaus.org/org/codehaus/groovy/modules/http-builder/http-builder/0.5.2-SNAPSHOT/http-builder-0.5.2-20110320.041601-11-all.tar.gz
http://snapshots.repository.codehaus.org/org/codehaus/groovy/modules/http-builder/http-builder/0.5.2-SNAPSHOT/http-builder-0.5.2-20110320.041601-11-all.zip

If you're not using version 0.5.2-SNAPSHOT of httpbuilder, you can find your appropriate version here:
http://snapshots.repository.codehaus.org/org/codehaus/groovy/modules/http-builder/http-builder/
or here:
http://repository.codehaus.org/org/codehaus/groovy/modules/http-builder/http-builder/


On Fri, May 6, 2011 at 3:52 PM, yuri2976 <[hidden email]> wrote:
I googled the missing jar, downloaded and added it to Build Path. Then groovy
complained about an another missing class, I downloaded it and the process
continued ad nauseum.

Is there a better way than to do all this manually?

--
View this message in context: http://groovy.329449.n5.nabble.com/problem-running-http-builder-code-tp3995735p4376962.html
Sent from the groovy - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email






If you reply to this email, your message will be added to the discussion below:
http://groovy.329449.n5.nabble.com/problem-running-http-builder-code-tp3995735p4376995.html
To unsubscribe from problem running http-builder code, click here.


View this message in context: Re: problem running http-builder code

Sent from the groovy - user mailing list archive at Nabble.com.

Loading...