http-builder RESTClient dependencies

Hi Jaimie,

I'm hoping you can help pointing me in the right direction, I'm receiving this class dependency in my logs :

2013-03-27 11:24:40,153 http-bio-8081-exec-1 ERROR [webwork.util.ValueStack] METHOD: "promotedLinks", exception:

java.lang.NoClassDefFoundError: groovy/lang/GroovyObject

while using:



import groovy.util.slurpersupport.GPathResult;

import static

def myRC = new RESTClient("http://localhost/")


I'm using the http-builder-0-1.7-20130216.204411-3.jar to access the RESTClient class.

I noticed that this class it's in the jar:


Should I install groovy-all-1.0-jsr-06.jar to resolve this dependency? Or should this be picked up by your groovyrunner jar?


1 answer

1 accepted

1 vote
Answer accepted

I decided to try apache's implementation instead, this script is called from another script and should really pass the rest_data parameter (needs to be cleaned up).

-rw-r--r-- 1 root root 115669 Mar 27 14:08 httpclient-cache-4.2.3.jar

-rw-r--r-- 1 root root 223571 Mar 27 13:53 httpcore-4.2.2.jar

-rw-r--r-- 1 root root 433070 Mar 27 13:51 httpclient-4.2.3.jar

Here is the script that eventually worked.

import groovy.sql.Sql;
import com.atlassian.jira.util.ImportUtils
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.IssueManager;
import groovy.json.*;
import java.util.ArrayList as ArrayList;
import java.sql.Connection;
import org.apache.log4j.Category;
import org.ofbiz.core.entity.ConnectionFactory;
import org.ofbiz.core.entity.DelegatorInterface;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;

log.error("sugarREST.groovy script " );
def username = "USERNAME";
def password = "PASSWORD";
def url = "http://localhost/service/v4/rest.php";
def restdata = new BasicNameValuePair("rest_data", '{"user_auth":{"user_name":"' + username + '","password":"' + MD5(password) + '","version":"1"},"application_name":"RestTest","name_value_list":[]}');
//println("restdata: " + restdata);

def result = call("login", restdata, url);
def session_id =;

//println("SESSION ID: " +;

//get list of records --------------------------------
def get_entry_list_parameters = new BasicNameValuePair("rest_data", '{"session" : "' + session_id + '", "module_name" : "Opportunities", "query" : "", "order_by" : "", "offset" : "0", \
     "fields" : ["name","description","start_date", "last_name", "end_date", "status", "nrc"], \
     "link_name_to_fields_array":[], "max_results":"2", "deleted":"0", "Favorites":false }');

//println("get_entry_list_parameters: " + get_entry_list_parameters);

def get_entry_list_result = call('get_entry_list', get_entry_list_parameters, url);

println("RESULTS: " + get_entry_list_result);

// sugar call
def call (method, rest_data, restURL) {
     def response = null;
     def returnVal = "";

     try {
      DefaultHttpClient client = new DefaultHttpClient();
      def post = new HttpPost(restURL);

      List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
      nameValuePairs.add(new BasicNameValuePair("method", "${method}"));
      nameValuePairs.add(new BasicNameValuePair("input_type", "JSON"));
      nameValuePairs.add(new BasicNameValuePair("response_type", "JSON"));

      post.setEntity(new UrlEncodedFormEntity(nameValuePairs));
      response = client.execute(post);
      BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
      String line = "";
      while ((line = rd.readLine()) != null) {
          returnVal = returnVal + line;
          //println ("LINE : " + line);

    } catch (e) {
      log.error("sugarREST.groovy failed, turn on stack trace to see the problem");

   if(returnVal && returnVal != null && returnVal != "null" ) {
      println ("VALUE: [" + returnVal + "]");
      def jsonObj = new JsonSlurper().parseText(returnVal);
      return jsonObj;
   } else {
      return null;

 def MD5(String s) {
    MessageDigest digest = MessageDigest.getInstance("MD5")
    new BigInteger(1, digest.digest()).toString(16).padLeft(32, '0')

It's a bit of a pain using httpbuilder, because, although it is excellent and easy to use, the maven dependencies include a load of xml stuff and httpcommons that conflicts with other libraries in use.

I spent a couple of days trying to wade through those dependencies which eventually led to conflicting calls. After that, it just wasn't worth the effort.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Wednesday in Marketplace Apps

Marketplace Spotlight: Marketing apps for Confluence to keep your teams working on the same page


189 views 0 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you