Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 848213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T06:54:28+00:00 2026-05-15T06:54:28+00:00

I’ve created a groovlet that will act as a sort of HTTP proxy. It

  • 0

I’ve created a groovlet that will act as a sort of HTTP proxy. It accepts GET requests and then makes web service calls based on the URL provided in the request.

Here’s the code I’ve got so far:

@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.5.0')
import groovyx.net.http.*
import static groovyx.net.http.ContentType.*
import static groovyx.net.http.Method.*

String url = params.url

def http = new HTTPBuilder(url)

http.request(GET, TEXT) {

     response.success = { resp, reader ->
       println reader
     }

     response.'404' = { resp -> 
       println 'not found!'
     }
}

I’ve got the Groovy HTTPBuilder JAR file in the WEB-INF/lib folder of the groovlet. However, the code isn’t working as it should. (I also tried putting the folder in $TOMCAT_HOME/common/lib with the same results as below.)

When I run the code exactly as it is above, the page comes back completely blank.

If I remove just the @Grab line at the top (since the JAR should theoretically be in the classpath already), I get a nasty error from Tomcat (I’m running it on 5.5, but I get roughly the same behavior on 6):

HTTP Status 500 – GroovyServlet Error:
script: ‘/proxy.groovy’: Script
processing failed.startup failed:
General error during semantic
analysis: Type
org.apache.http.client.methods.HttpRequestBase
not present
java.lang.TypeNotPresentException:
Type
org.apache.http.client.methods.HttpRequestBase
not present…

That is then followed by the stack trace.

What is wrong with my groovlet?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T06:54:29+00:00Added an answer on May 15, 2026 at 6:54 am

    Two things.

    First, it seems that Groovlets can’t use Grape (the @Grab command). That’s why the groovlet fails silently when this line is present.

    Second, the http-builder module also depends on about 19 other packages (including the org.apache.http.client.methods.HttpRequestBase that is referenced in the error message). You can find these packages in the ~/.groovy/grapes folder.

    If you want to find all the dependencies, delete the Grapes directory. Then run a script locally that uses that @Grab command. Once the script has finished executing, you can look in the Grapes directory and see everything it downloaded.

    When I did it, I got the following list of packages:

    antlr
    asm
    commons-beanutils
    commons-codec
    commons-collections
    commons-lang
    commons-logging
    net.sf.ezmorph
    net.sf.json-lib
    net.sourceforge.nekohtml
    org.apache
    org.apache.commons
    org.apache.httpcomponents
    org.codehaus.groovy
    org.codehaus.groovy.modules.http-builder
    xerces
    

    So if you want to use HttpBuilder in a groovlet, you’ll need to get all those dependencies in WEB-INF/lib or your Tomcat common/lib directory.

    On the other hand, if you don’t need anything terribly fancy, you can use the Groovy URL object. See some examples here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.