Note that there are some explanatory texts on larger screens.

plurals
  1. POTrying simple groovy script with grab and RESTClient
    primarykey
    data
    text
    <p>Using Groovy 2.1.7 with JDK 1.7.0_40.</p> <p>I'm trying to write a very simple prototype groovy script. It's going to call RESTClient and process the results from a service.</p> <p>It looks something like this:</p> <pre><code>#! env groovy @Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.5.2' ) @Grab(group='org.apache.httpcomponents', module='httpclient', version='4.1' ) import groovyx.net.http.RESTClient; println("About to create RESTClient."); service = new RESTClient("http://myhost/") def diagnostics = service.get(path: "mypath"); println("diagnostics[" + diagnostics + "]"); </code></pre> <p>When I run this, I get this:</p> <pre><code>About to create RESTClient. Caught: java.lang.NoClassDefFoundError: org/apache/http/client/methods/HttpUriRequest java.lang.NoClassDefFoundError: org/apache/http/client/methods/HttpUriRequest at monitorStatus.run(monitorStatus.groovy:9) Caused by: java.lang.ClassNotFoundException: org.apache.http.client.methods.HttpUriRequest ... 1 more </code></pre> <p>I saw one mention of needing to put the "@Grab" annotation on a method. I've tried several variations of this with thosee annotations on a method, but it made no difference.</p> <p>What am I doing wrong here?</p> <p><strong>EDIT:</strong> I added "-Dgroovy.grape.report.downloads=true" to my JAVA_OPTS and made some trivial changes to the script.</p> <p>Here is my current script, with just the url and path modified:</p> <pre><code>#! /usr/bin/env groovy @Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.5.2' ) @Grab(group='org.apache.httpcomponents', module='httpclient', version='4.2.5' ) import groovyx.net.http.RESTClient; import org.apache.http.client.HttpResponseException; import org.apache.http.client.methods.HttpUriRequest; println("About to create RESTClient."); service = new RESTClient("http:///") def diagnostics = service.get(path: "mypath"); println("diagnostics[" + diagnostics + "]"); </code></pre> <p>This is what I get when I run it:</p> <pre><code>Resolving dependency: org.apache.httpcomponents#httpclient;4.2.5 {default=[default]} Resolving dependency: org.codehaus.groovy.modules.http-builder#http-builder;0.5.2 {default=[default]} Preparing to download artifact org.apache.httpcomponents#httpclient;4.2.5!httpclient.jar Preparing to download artifact org.codehaus.groovy.modules.http-builder#http-builder;0.5.2!http-builder.jar Preparing to download artifact org.apache.httpcomponents#httpcore;4.2.4!httpcore.jar Preparing to download artifact commons-logging#commons-logging;1.1.1!commons-logging.jar Preparing to download artifact commons-codec#commons-codec;1.6!commons-codec.jar Preparing to download artifact net.sf.json-lib#json-lib;2.3!json-lib.jar Preparing to download artifact org.codehaus.groovy#groovy;1.7.11!groovy.jar Preparing to download artifact net.sourceforge.nekohtml#nekohtml;1.9.9!nekohtml.jar Preparing to download artifact xml-resolver#xml-resolver;1.2!xml-resolver.jar Preparing to download artifact commons-beanutils#commons-beanutils;1.8.0!commons-beanutils.jar Preparing to download artifact commons-collections#commons-collections;3.2.1!commons-collections.jar Preparing to download artifact commons-lang#commons-lang;2.4!commons-lang.jar Preparing to download artifact net.sf.ezmorph#ezmorph;1.0.6!ezmorph.jar Preparing to download artifact antlr#antlr;2.7.7!antlr.jar Preparing to download artifact asm#asm;3.2!asm.jar Preparing to download artifact asm#asm-commons;3.2!asm-commons.jar Preparing to download artifact asm#asm-util;3.2!asm-util.jar Preparing to download artifact asm#asm-analysis;3.2!asm-analysis.jar Preparing to download artifact asm#asm-tree;3.2!asm-tree.jar Preparing to download artifact xerces#xercesImpl;2.8.1!xercesImpl.jar Preparing to download artifact xml-apis#xml-apis;1.3.03!xml-apis.jar About to create RESTClient. Caught: java.lang.NoClassDefFoundError: org/apache/http/client/methods/HttpUriRequest java.lang.NoClassDefFoundError: org/apache/http/client/methods/HttpUriRequest at monitorSunlightDataSourceStatus.run(monitorSunlightDataSourceStatus.groovy:10) Caused by: java.lang.ClassNotFoundException: org.apache.http.client.methods.HttpUriRequest ... 1 more </code></pre> <p>Does this provide any useful clues?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload