You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@nifi.apache.org by Mike Harding <mi...@gmail.com> on 2017/05/04 17:58:30 UTC

Issue with Groovy script

Hi all,

I'm trying to run a simple groovy script in ExecuteScript processor to make
a HTTP GET request (I understand their are processors get this but I'm just
exploring Groovy at the minute).

import groovyx.net.http.HTTPBuilder
> flowFile = session.get()
> def http = new HTTPBuilder('https://google.com')
> def html = http.get(path : '/search', query : [q:'waffles'])
> log.warn(html)
> session.transfer(flowFile, REL_SUCCESS)


Ive included the http-builder jar as a dependency but I'm getting the error:

[image: Inline images 1]

I'm not new to NiFi but new to using Groovy. I've tried import
org.apache.http.* but that doesn't help. I'm assuming that the missing
class library is a default library in Groovy?

Any help much appreciated,
Mike

Re: Issue with Groovy script

Posted by Mike Harding <mi...@gmail.com>.
Thanks both - I assumed if I included the root directory that would not
only pick up the http-builder.jar but also the dependencies. Including the
dependencies directory fixed the issue.

Much appreciated,
Mike

On 4 May 2017 at 20:09, Matt Burgess <ma...@apache.org> wrote:

> Mike,
>
> To follow up on Andy's question, you will likely need more than just
> the http-builder JAR, I don't believe it is shaded (aka "fat JAR"). I
> have the "http-builder-0.7-all.zip" unzipped to a folder, and it has
> the http-builder-0.7.jar at the root level, but then a "dependencies"
> folder as well. If you have something similar, you will want to add
> the JAR and the dependencies folder to the Module Directory property.
>
> Regards,
> Matt
>
> On Thu, May 4, 2017 at 3:04 PM, Andy LoPresto <al...@apache.org>
> wrote:
> > Mike,
> >
> > When you say you’ve “included the http-builder jar as a dependency” do
> you
> > mean you provided the location of the directory containing that JAR as
> the
> > Module Path in the ExecuteScript processor?
> >
> > Andy LoPresto
> > alopresto@apache.org
> > alopresto.apache@gmail.com
> > PGP Fingerprint: 70EC B3E5 98A6 5A3F D3C4  BACE 3C6E F65B 2F7D EF69
> >
> > On May 4, 2017, at 1:58 PM, Mike Harding <mi...@gmail.com> wrote:
> >
> > Hi all,
> >
> > I'm trying to run a simple groovy script in ExecuteScript processor to
> make
> > a HTTP GET request (I understand their are processors get this but I'm
> just
> > exploring Groovy at the minute).
> >
> >> import groovyx.net.http.HTTPBuilder
> >> flowFile = session.get()
> >> def http = new HTTPBuilder('https://google.com')
> >> def html = http.get(path : '/search', query : [q:'waffles'])
> >> log.warn(html)
> >> session.transfer(flowFile, REL_SUCCESS)
> >
> >
> > Ive included the http-builder jar as a dependency but I'm getting the
> error:
> >
> > <image.png>
> >
> > I'm not new to NiFi but new to using Groovy. I've tried import
> > org.apache.http.* but that doesn't help. I'm assuming that the missing
> class
> > library is a default library in Groovy?
> >
> > Any help much appreciated,
> > Mike
> >
> >
>

Re: Issue with Groovy script

Posted by Matt Burgess <ma...@apache.org>.
Mike,

To follow up on Andy's question, you will likely need more than just
the http-builder JAR, I don't believe it is shaded (aka "fat JAR"). I
have the "http-builder-0.7-all.zip" unzipped to a folder, and it has
the http-builder-0.7.jar at the root level, but then a "dependencies"
folder as well. If you have something similar, you will want to add
the JAR and the dependencies folder to the Module Directory property.

Regards,
Matt

On Thu, May 4, 2017 at 3:04 PM, Andy LoPresto <al...@apache.org> wrote:
> Mike,
>
> When you say you’ve “included the http-builder jar as a dependency” do you
> mean you provided the location of the directory containing that JAR as the
> Module Path in the ExecuteScript processor?
>
> Andy LoPresto
> alopresto@apache.org
> alopresto.apache@gmail.com
> PGP Fingerprint: 70EC B3E5 98A6 5A3F D3C4  BACE 3C6E F65B 2F7D EF69
>
> On May 4, 2017, at 1:58 PM, Mike Harding <mi...@gmail.com> wrote:
>
> Hi all,
>
> I'm trying to run a simple groovy script in ExecuteScript processor to make
> a HTTP GET request (I understand their are processors get this but I'm just
> exploring Groovy at the minute).
>
>> import groovyx.net.http.HTTPBuilder
>> flowFile = session.get()
>> def http = new HTTPBuilder('https://google.com')
>> def html = http.get(path : '/search', query : [q:'waffles'])
>> log.warn(html)
>> session.transfer(flowFile, REL_SUCCESS)
>
>
> Ive included the http-builder jar as a dependency but I'm getting the error:
>
> <image.png>
>
> I'm not new to NiFi but new to using Groovy. I've tried import
> org.apache.http.* but that doesn't help. I'm assuming that the missing class
> library is a default library in Groovy?
>
> Any help much appreciated,
> Mike
>
>

Re: Issue with Groovy script

Posted by Andy LoPresto <al...@apache.org>.
Mike,

When you say you’ve “included the http-builder jar as a dependency” do you mean you provided the location of the directory containing that JAR as the Module Path in the ExecuteScript processor?

Andy LoPresto
alopresto@apache.org
alopresto.apache@gmail.com
PGP Fingerprint: 70EC B3E5 98A6 5A3F D3C4  BACE 3C6E F65B 2F7D EF69

> On May 4, 2017, at 1:58 PM, Mike Harding <mi...@gmail.com> wrote:
> 
> Hi all,
> 
> I'm trying to run a simple groovy script in ExecuteScript processor to make a HTTP GET request (I understand their are processors get this but I'm just exploring Groovy at the minute).
> 
> import groovyx.net.http.HTTPBuilder
> flowFile = session.get()
> def http = new HTTPBuilder('https://google.com <https://google.com/>')
> def html = http.get(path : '/search', query : [q:'waffles'])
> log.warn(html)
> session.transfer(flowFile, REL_SUCCESS)
> 
> Ive included the http-builder jar as a dependency but I'm getting the error:
> 
> <image.png>
> 
> I'm not new to NiFi but new to using Groovy. I've tried import org.apache.http.* but that doesn't help. I'm assuming that the missing class library is a default library in Groovy?
> 
> Any help much appreciated,
> Mike