Problem running a Groovy script from within Eclipse

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem running a Groovy script from within Eclipse

Tom Harris

Groovy-Eclipse plugin developers:

I have a pretty simple script I'm running, and I've been struggling to get it working for two days. Excerpt:


// some imports...

line 13: CustomConfigUtil.setPropertyFilename(args[0])

line 14: ConfigObject conf = CustomConfigUtil.getConf()

line 15: Log.info("conf=${conf}") // prints happy things, so we did in fact load the config data

line 16: CustomUtilObject customUtilObject = new CustomUtilObject(conf)

// etc...


When I attempt to run the script using the Run as... "Groovy Script" with the appropriate parameters and such, I see the conf=${conf} Log line with full data loaded, but then the error:

Caught: groovy.lang.GroovyRuntimeException: failed to invoke constructor: public CustomUtilObject(groovy.util.ConfigObject) with arguments: [] reason: java.lang.IllegalArgumentException: wrong number of arguments

groovy.lang.GroovyRuntimeException: failed to invoke constructor: public CustomUtilObject(groovy.util.ConfigObject) with arguments: [] reason: java.lang.IllegalArgumentException: wrong number of arguments

at MyScript.run(MyScript.groovy:16)


I have tried to use "new CustomUtilObject(conf: conf)" as well, same error.

The CustomUtilObject class in fact does have a single argument constructor:


    CustomUtilObject(ConfigObject conf) {

        this.conf = conf

    }


I'm at a complete loss as to why this is failing, and two days now have passed with no solution. Can anyone help? Thanks.


Tom Harris

Zemoga, Inc.


Reply | Threaded
Open this post in threaded view
|

Re: Problem running a Groovy script from within Eclipse

Andrew Eisenberg
What version of groovy are you using?  Are you using the same version
of groovy on the command line as in Eclipse?  Is CustomUtilObject one
of your classes or is it a library class?

Also, what happens if you try running as a java app?

On Thu, Jun 21, 2012 at 9:41 AM, Tom Harris <[hidden email]> wrote:

>
> Groovy-Eclipse plugin developers:
>
> I have a pretty simple script I'm running, and I've been struggling to get
> it working for two days. Excerpt:
>
>
> // some imports...
>
> line 13: CustomConfigUtil.setPropertyFilename(args[0])
>
> line 14: ConfigObject conf = CustomConfigUtil.getConf()
>
> line 15: Log.info("conf=${conf}") // prints happy things, so we did in fact
> load the config data
>
> line 16: CustomUtilObject customUtilObject = new CustomUtilObject(conf)
>
> // etc...
>
>
> When I attempt to run the script using the Run as... "Groovy Script" with
> the appropriate parameters and such, I see the conf=${conf} Log line with
> full data loaded, but then the error:
>
> Caught: groovy.lang.GroovyRuntimeException: failed to invoke constructor:
> public CustomUtilObject(groovy.util.ConfigObject) with arguments: [] reason:
> java.lang.IllegalArgumentException: wrong number of arguments
>
> groovy.lang.GroovyRuntimeException: failed to invoke constructor:
> public CustomUtilObject(groovy.util.ConfigObject) with arguments: [] reason:
> java.lang.IllegalArgumentException: wrong number of arguments
>
> at MyScript.run(MyScript.groovy:16)
>
>
> I have tried to use "new CustomUtilObject(conf: conf)" as well, same error.
>
> The CustomUtilObject class in fact does have a single argument constructor:
>
>
>     CustomUtilObject(ConfigObject conf) {
>
>         this.conf = conf
>
>     }
>
>
> I'm at a complete loss as to why this is failing, and two days now have
> passed with no solution. Can anyone help? Thanks.
>
>
> Tom Harris
>
> Zemoga, Inc.
>
>

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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Problem running a Groovy script from within Eclipse

Tom Harris


This is the latest groovy-eclipse-plugin 2.6.1.xx-20120301-1000-e37-RELEASE, with groovy compiler 1.8.6.xx-20120301-1000-e37-RELEASE.

I'm not using anything from a command line, only from within Eclipse, as I want to be able to debug through the script.

CustomUtilObject is a custom groovy class that I'm using, which was written for use by another script. The other two developers on the team, who originally wrote the CustomUtilObject class use only IntelliJ IDEA IDE, but I've been an Eclipse user forever, and have no interest in configuring and learning to use a commercial IDE.

How would one go about running a groovy script as a Java app? That doesn't sound like an option to me, as there's no Java main method or anything in the file.

I'm pretty new to Groovy, been doing Java development since 1999.

Tom Harris
Zemoga, Inc.


On Thu, Jun 21, 2012 at 1:43 PM, Andrew Eisenberg <[hidden email]> wrote:
What version of groovy are you using?  Are you using the same version
of groovy on the command line as in Eclipse?  Is CustomUtilObject one
of your classes or is it a library class?

Also, what happens if you try running as a java app?

On Thu, Jun 21, 2012 at 9:41 AM, Tom Harris <[hidden email]> wrote:
>
> Groovy-Eclipse plugin developers:
>
> I have a pretty simple script I'm running, and I've been struggling to get
> it working for two days. Excerpt:
>
>
> // some imports...
>
> line 13: CustomConfigUtil.setPropertyFilename(args[0])
>
> line 14: ConfigObject conf = CustomConfigUtil.getConf()
>
> line 15: Log.info("conf=${conf}") // prints happy things, so we did in fact
> load the config data
>
> line 16: CustomUtilObject customUtilObject = new CustomUtilObject(conf)
>
> // etc...
>
>
> When I attempt to run the script using the Run as... "Groovy Script" with
> the appropriate parameters and such, I see the conf=${conf} Log line with
> full data loaded, but then the error:
>
> Caught: groovy.lang.GroovyRuntimeException: failed to invoke constructor:
> public CustomUtilObject(groovy.util.ConfigObject) with arguments: [] reason:
> java.lang.IllegalArgumentException: wrong number of arguments
>
> groovy.lang.GroovyRuntimeException: failed to invoke constructor:
> public CustomUtilObject(groovy.util.ConfigObject) with arguments: [] reason:
> java.lang.IllegalArgumentException: wrong number of arguments
>
> at MyScript.run(MyScript.groovy:16)
>
>
> I have tried to use "new CustomUtilObject(conf: conf)" as well, same error.
>
> The CustomUtilObject class in fact does have a single argument constructor:
>
>
>     CustomUtilObject(ConfigObject conf) {
>
>         this.conf = conf
>
>     }
>
>
> I'm at a complete loss as to why this is failing, and two days now have
> passed with no solution. Can anyone help? Thanks.
>
>
> Tom Harris
>
> Zemoga, Inc.
>
>

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

   http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|

Re: Problem running a Groovy script from within Eclipse

Andrew Eisenberg
So, CustomUtilObject is another script in the same project?

You should be able to run your script as a Java app.  Just right-click
-> Run as -> Java App.  There is a main method in the generated class
file.  That is what is being used when you do run as java app.

What happens when you set a breakpoint at line 16 and step into the
code?  Can you see what class Groovy is trying to load?  What happens
when you navigate to the class?

On Thu, Jun 21, 2012 at 11:01 AM, Tom Harris <[hidden email]> wrote:

>
>
> This is the latest groovy-eclipse-plugin 2.6.1.xx-20120301-1000-e37-RELEASE,
> with groovy compiler 1.8.6.xx-20120301-1000-e37-RELEASE.
>
> I'm not using anything from a command line, only from within Eclipse, as I
> want to be able to debug through the script.
>
> CustomUtilObject is a custom groovy class that I'm using, which was written
> for use by another script. The other two developers on the team, who
> originally wrote the CustomUtilObject class use only IntelliJ IDEA IDE, but
> I've been an Eclipse user forever, and have no interest in configuring and
> learning to use a commercial IDE.
>
> How would one go about running a groovy script as a Java app? That doesn't
> sound like an option to me, as there's no Java main method or anything in
> the file.
>
> I'm pretty new to Groovy, been doing Java development since 1999.
>
> Tom Harris
> Zemoga, Inc.
>
>
> On Thu, Jun 21, 2012 at 1:43 PM, Andrew Eisenberg <[hidden email]>
> wrote:
>>
>> What version of groovy are you using?  Are you using the same version
>> of groovy on the command line as in Eclipse?  Is CustomUtilObject one
>> of your classes or is it a library class?
>>
>> Also, what happens if you try running as a java app?
>>
>> On Thu, Jun 21, 2012 at 9:41 AM, Tom Harris <[hidden email]> wrote:
>> >
>> > Groovy-Eclipse plugin developers:
>> >
>> > I have a pretty simple script I'm running, and I've been struggling to
>> > get
>> > it working for two days. Excerpt:
>> >
>> >
>> > // some imports...
>> >
>> > line 13: CustomConfigUtil.setPropertyFilename(args[0])
>> >
>> > line 14: ConfigObject conf = CustomConfigUtil.getConf()
>> >
>> > line 15: Log.info("conf=${conf}") // prints happy things, so we did in
>> > fact
>> > load the config data
>> >
>> > line 16: CustomUtilObject customUtilObject = new CustomUtilObject(conf)
>> >
>> > // etc...
>> >
>> >
>> > When I attempt to run the script using the Run as... "Groovy Script"
>> > with
>> > the appropriate parameters and such, I see the conf=${conf} Log line
>> > with
>> > full data loaded, but then the error:
>> >
>> > Caught: groovy.lang.GroovyRuntimeException: failed to invoke
>> > constructor:
>> > public CustomUtilObject(groovy.util.ConfigObject) with arguments: []
>> > reason:
>> > java.lang.IllegalArgumentException: wrong number of arguments
>> >
>> > groovy.lang.GroovyRuntimeException: failed to invoke constructor:
>> > public CustomUtilObject(groovy.util.ConfigObject) with arguments: []
>> > reason:
>> > java.lang.IllegalArgumentException: wrong number of arguments
>> >
>> > at MyScript.run(MyScript.groovy:16)
>> >
>> >
>> > I have tried to use "new CustomUtilObject(conf: conf)" as well, same
>> > error.
>> >
>> > The CustomUtilObject class in fact does have a single argument
>> > constructor:
>> >
>> >
>> >     CustomUtilObject(ConfigObject conf) {
>> >
>> >         this.conf = conf
>> >
>> >     }
>> >
>> >
>> > I'm at a complete loss as to why this is failing, and two days now have
>> > passed with no solution. Can anyone help? Thanks.
>> >
>> >
>> > Tom Harris
>> >
>> > Zemoga, Inc.
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>

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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Problem running a Groovy script from within Eclipse

Tom Harris

Well, it's a Groovy class defined in a file called CustomUtilObject.groovy within the src/main/groovy folder of the project. It's not a script. The script file that I'm running directly had to be located in the target folder of the project.

When I attempt to Run as... Java Appllcation, I just get a failure popup that says 'Selection does not contain a main type'.

I attempted a few times to debug through to the failure, but it goes pretty deep into Unknown Source of groovy code and then fails before it ever comes back out to my script.

I can navigate to the CustomUtilObject constructor using Fn+F3 (on my Mac) from the script line 16, with no issue.

Thanks a lot for helping me out on this.

Tom

On Thu, Jun 21, 2012 at 2:36 PM, Andrew Eisenberg <[hidden email]> wrote:
So, CustomUtilObject is another script in the same project?

You should be able to run your script as a Java app.  Just right-click
-> Run as -> Java App.  There is a main method in the generated class
file.  That is what is being used when you do run as java app.

What happens when you set a breakpoint at line 16 and step into the
code?  Can you see what class Groovy is trying to load?  What happens
when you navigate to the class?

On Thu, Jun 21, 2012 at 11:01 AM, Tom Harris <[hidden email]> wrote:
>
>
> This is the latest groovy-eclipse-plugin 2.6.1.xx-20120301-1000-e37-RELEASE,
> with groovy compiler 1.8.6.xx-20120301-1000-e37-RELEASE.
>
> I'm not using anything from a command line, only from within Eclipse, as I
> want to be able to debug through the script.
>
> CustomUtilObject is a custom groovy class that I'm using, which was written
> for use by another script. The other two developers on the team, who
> originally wrote the CustomUtilObject class use only IntelliJ IDEA IDE, but
> I've been an Eclipse user forever, and have no interest in configuring and
> learning to use a commercial IDE.
>
> How would one go about running a groovy script as a Java app? That doesn't
> sound like an option to me, as there's no Java main method or anything in
> the file.
>
> I'm pretty new to Groovy, been doing Java development since 1999.
>
> Tom Harris
> Zemoga, Inc.
>
>
> On Thu, Jun 21, 2012 at 1:43 PM, Andrew Eisenberg <[hidden email]>
> wrote:
>>
>> What version of groovy are you using?  Are you using the same version
>> of groovy on the command line as in Eclipse?  Is CustomUtilObject one
>> of your classes or is it a library class?
>>
>> Also, what happens if you try running as a java app?
>>
>> On Thu, Jun 21, 2012 at 9:41 AM, Tom Harris <[hidden email]> wrote:
>> >
>> > Groovy-Eclipse plugin developers:
>> >
>> > I have a pretty simple script I'm running, and I've been struggling to
>> > get
>> > it working for two days. Excerpt:
>> >
>> >
>> > // some imports...
>> >
>> > line 13: CustomConfigUtil.setPropertyFilename(args[0])
>> >
>> > line 14: ConfigObject conf = CustomConfigUtil.getConf()
>> >
>> > line 15: Log.info("conf=${conf}") // prints happy things, so we did in
>> > fact
>> > load the config data
>> >
>> > line 16: CustomUtilObject customUtilObject = new CustomUtilObject(conf)
>> >
>> > // etc...
>> >
>> >
>> > When I attempt to run the script using the Run as... "Groovy Script"
>> > with
>> > the appropriate parameters and such, I see the conf=${conf} Log line
>> > with
>> > full data loaded, but then the error:
>> >
>> > Caught: groovy.lang.GroovyRuntimeException: failed to invoke
>> > constructor:
>> > public CustomUtilObject(groovy.util.ConfigObject) with arguments: []
>> > reason:
>> > java.lang.IllegalArgumentException: wrong number of arguments
>> >
>> > groovy.lang.GroovyRuntimeException: failed to invoke constructor:
>> > public CustomUtilObject(groovy.util.ConfigObject) with arguments: []
>> > reason:
>> > java.lang.IllegalArgumentException: wrong number of arguments
>> >
>> > at MyScript.run(MyScript.groovy:16)
>> >
>> >
>> > I have tried to use "new CustomUtilObject(conf: conf)" as well, same
>> > error.
>> >
>> > The CustomUtilObject class in fact does have a single argument
>> > constructor:
>> >
>> >
>> >     CustomUtilObject(ConfigObject conf) {
>> >
>> >         this.conf = conf
>> >
>> >     }
>> >
>> >
>> > I'm at a complete loss as to why this is failing, and two days now have
>> > passed with no solution. Can anyone help? Thanks.
>> >
>> >
>> > Tom Harris
>> >
>> > Zemoga, Inc.
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>

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

   http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|

Re: Problem running a Groovy script from within Eclipse

Andrew Eisenberg
> When I attempt to Run as... Java Appllcation, I just get a failure popup
> that says 'Selection does not contain a main type'.

That's odd.  Shouldn't be.  Scripts do have a main type.

I take it that this is a maven project, then.  Are you using
m2eclipse?  Is src/main/groovy on the build path (I'm guessing no,
which would explain the lack of a main type)?  Are you using script
folders (go to Preferences -> Groovy -> Compiler)?


>
> I attempted a few times to debug through to the failure, but it goes pretty
> deep into Unknown Source of groovy code and then fails before it ever comes
> back out to my script.
>
> I can navigate to the CustomUtilObject constructor using Fn+F3 (on my Mac)
> from the script line 16, with no issue.
>
> Thanks a lot for helping me out on this.
>
> Tom
>
> On Thu, Jun 21, 2012 at 2:36 PM, Andrew Eisenberg <[hidden email]>
> wrote:
>>
>> So, CustomUtilObject is another script in the same project?
>>
>> You should be able to run your script as a Java app.  Just right-click
>> -> Run as -> Java App.  There is a main method in the generated class
>> file.  That is what is being used when you do run as java app.
>>
>> What happens when you set a breakpoint at line 16 and step into the
>> code?  Can you see what class Groovy is trying to load?  What happens
>> when you navigate to the class?
>>
>> On Thu, Jun 21, 2012 at 11:01 AM, Tom Harris <[hidden email]>
>> wrote:
>> >
>> >
>> > This is the latest groovy-eclipse-plugin
>> > 2.6.1.xx-20120301-1000-e37-RELEASE,
>> > with groovy compiler 1.8.6.xx-20120301-1000-e37-RELEASE.
>> >
>> > I'm not using anything from a command line, only from within Eclipse, as
>> > I
>> > want to be able to debug through the script.
>> >
>> > CustomUtilObject is a custom groovy class that I'm using, which was
>> > written
>> > for use by another script. The other two developers on the team, who
>> > originally wrote the CustomUtilObject class use only IntelliJ IDEA IDE,
>> > but
>> > I've been an Eclipse user forever, and have no interest in configuring
>> > and
>> > learning to use a commercial IDE.
>> >
>> > How would one go about running a groovy script as a Java app? That
>> > doesn't
>> > sound like an option to me, as there's no Java main method or anything
>> > in
>> > the file.
>> >
>> > I'm pretty new to Groovy, been doing Java development since 1999.
>> >
>> > Tom Harris
>> > Zemoga, Inc.
>> >
>> >
>> > On Thu, Jun 21, 2012 at 1:43 PM, Andrew Eisenberg <[hidden email]>
>> > wrote:
>> >>
>> >> What version of groovy are you using?  Are you using the same version
>> >> of groovy on the command line as in Eclipse?  Is CustomUtilObject one
>> >> of your classes or is it a library class?
>> >>
>> >> Also, what happens if you try running as a java app?
>> >>
>> >> On Thu, Jun 21, 2012 at 9:41 AM, Tom Harris <[hidden email]>
>> >> wrote:
>> >> >
>> >> > Groovy-Eclipse plugin developers:
>> >> >
>> >> > I have a pretty simple script I'm running, and I've been struggling
>> >> > to
>> >> > get
>> >> > it working for two days. Excerpt:
>> >> >
>> >> >
>> >> > // some imports...
>> >> >
>> >> > line 13: CustomConfigUtil.setPropertyFilename(args[0])
>> >> >
>> >> > line 14: ConfigObject conf = CustomConfigUtil.getConf()
>> >> >
>> >> > line 15: Log.info("conf=${conf}") // prints happy things, so we did
>> >> > in
>> >> > fact
>> >> > load the config data
>> >> >
>> >> > line 16: CustomUtilObject customUtilObject =
>> >> > new CustomUtilObject(conf)
>> >> >
>> >> > // etc...
>> >> >
>> >> >
>> >> > When I attempt to run the script using the Run as... "Groovy Script"
>> >> > with
>> >> > the appropriate parameters and such, I see the conf=${conf} Log line
>> >> > with
>> >> > full data loaded, but then the error:
>> >> >
>> >> > Caught: groovy.lang.GroovyRuntimeException: failed to invoke
>> >> > constructor:
>> >> > public CustomUtilObject(groovy.util.ConfigObject) with arguments: []
>> >> > reason:
>> >> > java.lang.IllegalArgumentException: wrong number of arguments
>> >> >
>> >> > groovy.lang.GroovyRuntimeException: failed to invoke constructor:
>> >> > public CustomUtilObject(groovy.util.ConfigObject) with arguments: []
>> >> > reason:
>> >> > java.lang.IllegalArgumentException: wrong number of arguments
>> >> >
>> >> > at MyScript.run(MyScript.groovy:16)
>> >> >
>> >> >
>> >> > I have tried to use "new CustomUtilObject(conf: conf)" as well, same
>> >> > error.
>> >> >
>> >> > The CustomUtilObject class in fact does have a single argument
>> >> > constructor:
>> >> >
>> >> >
>> >> >     CustomUtilObject(ConfigObject conf) {
>> >> >
>> >> >         this.conf = conf
>> >> >
>> >> >     }
>> >> >
>> >> >
>> >> > I'm at a complete loss as to why this is failing, and two days now
>> >> > have
>> >> > passed with no solution. Can anyone help? Thanks.
>> >> >
>> >> >
>> >> > Tom Harris
>> >> >
>> >> > Zemoga, Inc.
>> >> >
>> >> >
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe from this list, please visit:
>> >>
>> >>    http://xircles.codehaus.org/manage_email
>> >>
>> >>
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>

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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Problem running a Groovy script from within Eclipse

Tom Harris

The project does have a pom.xml in it, though I'm not using it. The src/main/groovy source folder is defined, and so it should be part of the build path. I tried turning on "Enable script folder support", but it didn't help at all. I tried moving my script file into a new folder named "scripts" in the project root, and setting one of the enabled script folders to be that one, but nothing helped... I still keep getting this error.

I tried to debug further, but the Mac version of the Java VM doesn't seem to have the source code in it like its Windows counterparts. So, as soon as it gets to line 16, it starts trying to run Class.forName() unknown source... and I can no longer follow what its doing... It seems to play inside String.class for a long time, some Groovy classes are shown in the stack as well, but eventually, I get the same error tossed up without any reason.

Tom

On Thu, Jun 21, 2012 at 3:31 PM, Andrew Eisenberg <[hidden email]> wrote:
> When I attempt to Run as... Java Appllcation, I just get a failure popup
> that says 'Selection does not contain a main type'.

That's odd.  Shouldn't be.  Scripts do have a main type.

I take it that this is a maven project, then.  Are you using
m2eclipse?  Is src/main/groovy on the build path (I'm guessing no,
which would explain the lack of a main type)?  Are you using script
folders (go to Preferences -> Groovy -> Compiler)?


>
> I attempted a few times to debug through to the failure, but it goes pretty
> deep into Unknown Source of groovy code and then fails before it ever comes
> back out to my script.
>
> I can navigate to the CustomUtilObject constructor using Fn+F3 (on my Mac)
> from the script line 16, with no issue.
>
> Thanks a lot for helping me out on this.
>
> Tom
>
> On Thu, Jun 21, 2012 at 2:36 PM, Andrew Eisenberg <[hidden email]>
> wrote:
>>
>> So, CustomUtilObject is another script in the same project?
>>
>> You should be able to run your script as a Java app.  Just right-click
>> -> Run as -> Java App.  There is a main method in the generated class
>> file.  That is what is being used when you do run as java app.
>>
>> What happens when you set a breakpoint at line 16 and step into the
>> code?  Can you see what class Groovy is trying to load?  What happens
>> when you navigate to the class?
>>
>> On Thu, Jun 21, 2012 at 11:01 AM, Tom Harris <[hidden email]>
>> wrote:
>> >
>> >
>> > This is the latest groovy-eclipse-plugin
>> > 2.6.1.xx-20120301-1000-e37-RELEASE,
>> > with groovy compiler 1.8.6.xx-20120301-1000-e37-RELEASE.
>> >
>> > I'm not using anything from a command line, only from within Eclipse, as
>> > I
>> > want to be able to debug through the script.
>> >
>> > CustomUtilObject is a custom groovy class that I'm using, which was
>> > written
>> > for use by another script. The other two developers on the team, who
>> > originally wrote the CustomUtilObject class use only IntelliJ IDEA IDE,
>> > but
>> > I've been an Eclipse user forever, and have no interest in configuring
>> > and
>> > learning to use a commercial IDE.
>> >
>> > How would one go about running a groovy script as a Java app? That
>> > doesn't
>> > sound like an option to me, as there's no Java main method or anything
>> > in
>> > the file.
>> >
>> > I'm pretty new to Groovy, been doing Java development since 1999.
>> >
>> > Tom Harris
>> > Zemoga, Inc.
>> >
>> >
>> > On Thu, Jun 21, 2012 at 1:43 PM, Andrew Eisenberg <[hidden email]>
>> > wrote:
>> >>
>> >> What version of groovy are you using?  Are you using the same version
>> >> of groovy on the command line as in Eclipse?  Is CustomUtilObject one
>> >> of your classes or is it a library class?
>> >>
>> >> Also, what happens if you try running as a java app?
>> >>
>> >> On Thu, Jun 21, 2012 at 9:41 AM, Tom Harris <[hidden email]>
>> >> wrote:
>> >> >
>> >> > Groovy-Eclipse plugin developers:
>> >> >
>> >> > I have a pretty simple script I'm running, and I've been struggling
>> >> > to
>> >> > get
>> >> > it working for two days. Excerpt:
>> >> >
>> >> >
>> >> > // some imports...
>> >> >
>> >> > line 13: CustomConfigUtil.setPropertyFilename(args[0])
>> >> >
>> >> > line 14: ConfigObject conf = CustomConfigUtil.getConf()
>> >> >
>> >> > line 15: Log.info("conf=${conf}") // prints happy things, so we did
>> >> > in
>> >> > fact
>> >> > load the config data
>> >> >
>> >> > line 16: CustomUtilObject customUtilObject =
>> >> > new CustomUtilObject(conf)
>> >> >
>> >> > // etc...
>> >> >
>> >> >
>> >> > When I attempt to run the script using the Run as... "Groovy Script"
>> >> > with
>> >> > the appropriate parameters and such, I see the conf=${conf} Log line
>> >> > with
>> >> > full data loaded, but then the error:
>> >> >
>> >> > Caught: groovy.lang.GroovyRuntimeException: failed to invoke
>> >> > constructor:
>> >> > public CustomUtilObject(groovy.util.ConfigObject) with arguments: []
>> >> > reason:
>> >> > java.lang.IllegalArgumentException: wrong number of arguments
>> >> >
>> >> > groovy.lang.GroovyRuntimeException: failed to invoke constructor:
>> >> > public CustomUtilObject(groovy.util.ConfigObject) with arguments: []
>> >> > reason:
>> >> > java.lang.IllegalArgumentException: wrong number of arguments
>> >> >
>> >> > at MyScript.run(MyScript.groovy:16)
>> >> >
>> >> >
>> >> > I have tried to use "new CustomUtilObject(conf: conf)" as well, same
>> >> > error.
>> >> >
>> >> > The CustomUtilObject class in fact does have a single argument
>> >> > constructor:
>> >> >
>> >> >
>> >> >     CustomUtilObject(ConfigObject conf) {
>> >> >
>> >> >         this.conf = conf
>> >> >
>> >> >     }
>> >> >
>> >> >
>> >> > I'm at a complete loss as to why this is failing, and two days now
>> >> > have
>> >> > passed with no solution. Can anyone help? Thanks.
>> >> >
>> >> >
>> >> > Tom Harris
>> >> >
>> >> > Zemoga, Inc.
>> >> >
>> >> >
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe from this list, please visit:
>> >>
>> >>    http://xircles.codehaus.org/manage_email
>> >>
>> >>
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>

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

   http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|

Re: Problem running a Groovy script from within Eclipse

Andrew Eisenberg
I feel like there's something I'm not getting, or else there is a bug
here.  If you can, you can send the project to me (not to the mailing
list if there's proprietary code).  I can try to figure out what's
going on.

Getting the JDK source code on mac is a pain.  You need to download
xcode and jump through about 10 more hoops.  But, the source code for
Groovy is included in the groovy-eclipse distribution.

On Thu, Jun 21, 2012 at 12:41 PM, Tom Harris <[hidden email]> wrote:

>
> The project does have a pom.xml in it, though I'm not using it. The
> src/main/groovy source folder is defined, and so it should be part of the
> build path. I tried turning on "Enable script folder support", but it didn't
> help at all. I tried moving my script file into a new folder named "scripts"
> in the project root, and setting one of the enabled script folders to be
> that one, but nothing helped... I still keep getting this error.
>
> I tried to debug further, but the Mac version of the Java VM doesn't seem to
> have the source code in it like its Windows counterparts. So, as soon as it
> gets to line 16, it starts trying to run Class.forName() unknown source...
> and I can no longer follow what its doing... It seems to play inside
> String.class for a long time, some Groovy classes are shown in the stack as
> well, but eventually, I get the same error tossed up without any reason.
>
> Tom
>
>
> On Thu, Jun 21, 2012 at 3:31 PM, Andrew Eisenberg <[hidden email]>
> wrote:
>>
>> > When I attempt to Run as... Java Appllcation, I just get a failure popup
>> > that says 'Selection does not contain a main type'.
>>
>> That's odd.  Shouldn't be.  Scripts do have a main type.
>>
>> I take it that this is a maven project, then.  Are you using
>> m2eclipse?  Is src/main/groovy on the build path (I'm guessing no,
>> which would explain the lack of a main type)?  Are you using script
>> folders (go to Preferences -> Groovy -> Compiler)?
>>
>>
>> >
>> > I attempted a few times to debug through to the failure, but it goes
>> > pretty
>> > deep into Unknown Source of groovy code and then fails before it ever
>> > comes
>> > back out to my script.
>> >
>> > I can navigate to the CustomUtilObject constructor using Fn+F3 (on my
>> > Mac)
>> > from the script line 16, with no issue.
>> >
>> > Thanks a lot for helping me out on this.
>> >
>> > Tom
>> >
>> > On Thu, Jun 21, 2012 at 2:36 PM, Andrew Eisenberg <[hidden email]>
>> > wrote:
>> >>
>> >> So, CustomUtilObject is another script in the same project?
>> >>
>> >> You should be able to run your script as a Java app.  Just right-click
>> >> -> Run as -> Java App.  There is a main method in the generated class
>> >> file.  That is what is being used when you do run as java app.
>> >>
>> >> What happens when you set a breakpoint at line 16 and step into the
>> >> code?  Can you see what class Groovy is trying to load?  What happens
>> >> when you navigate to the class?
>> >>
>> >> On Thu, Jun 21, 2012 at 11:01 AM, Tom Harris <[hidden email]>
>> >> wrote:
>> >> >
>> >> >
>> >> > This is the latest groovy-eclipse-plugin
>> >> > 2.6.1.xx-20120301-1000-e37-RELEASE,
>> >> > with groovy compiler 1.8.6.xx-20120301-1000-e37-RELEASE.
>> >> >
>> >> > I'm not using anything from a command line, only from within Eclipse,
>> >> > as
>> >> > I
>> >> > want to be able to debug through the script.
>> >> >
>> >> > CustomUtilObject is a custom groovy class that I'm using, which was
>> >> > written
>> >> > for use by another script. The other two developers on the team, who
>> >> > originally wrote the CustomUtilObject class use only IntelliJ IDEA
>> >> > IDE,
>> >> > but
>> >> > I've been an Eclipse user forever, and have no interest in
>> >> > configuring
>> >> > and
>> >> > learning to use a commercial IDE.
>> >> >
>> >> > How would one go about running a groovy script as a Java app? That
>> >> > doesn't
>> >> > sound like an option to me, as there's no Java main method or
>> >> > anything
>> >> > in
>> >> > the file.
>> >> >
>> >> > I'm pretty new to Groovy, been doing Java development since 1999.
>> >> >
>> >> > Tom Harris
>> >> > Zemoga, Inc.
>> >> >
>> >> >
>> >> > On Thu, Jun 21, 2012 at 1:43 PM, Andrew Eisenberg
>> >> > <[hidden email]>
>> >> > wrote:
>> >> >>
>> >> >> What version of groovy are you using?  Are you using the same
>> >> >> version
>> >> >> of groovy on the command line as in Eclipse?  Is CustomUtilObject
>> >> >> one
>> >> >> of your classes or is it a library class?
>> >> >>
>> >> >> Also, what happens if you try running as a java app?
>> >> >>
>> >> >> On Thu, Jun 21, 2012 at 9:41 AM, Tom Harris <[hidden email]>
>> >> >> wrote:
>> >> >> >
>> >> >> > Groovy-Eclipse plugin developers:
>> >> >> >
>> >> >> > I have a pretty simple script I'm running, and I've been
>> >> >> > struggling
>> >> >> > to
>> >> >> > get
>> >> >> > it working for two days. Excerpt:
>> >> >> >
>> >> >> >
>> >> >> > // some imports...
>> >> >> >
>> >> >> > line 13: CustomConfigUtil.setPropertyFilename(args[0])
>> >> >> >
>> >> >> > line 14: ConfigObject conf = CustomConfigUtil.getConf()
>> >> >> >
>> >> >> > line 15: Log.info("conf=${conf}") // prints happy things, so we
>> >> >> > did
>> >> >> > in
>> >> >> > fact
>> >> >> > load the config data
>> >> >> >
>> >> >> > line 16: CustomUtilObject customUtilObject =
>> >> >> > new CustomUtilObject(conf)
>> >> >> >
>> >> >> > // etc...
>> >> >> >
>> >> >> >
>> >> >> > When I attempt to run the script using the Run as... "Groovy
>> >> >> > Script"
>> >> >> > with
>> >> >> > the appropriate parameters and such, I see the conf=${conf} Log
>> >> >> > line
>> >> >> > with
>> >> >> > full data loaded, but then the error:
>> >> >> >
>> >> >> > Caught: groovy.lang.GroovyRuntimeException: failed to invoke
>> >> >> > constructor:
>> >> >> > public CustomUtilObject(groovy.util.ConfigObject) with arguments:
>> >> >> > []
>> >> >> > reason:
>> >> >> > java.lang.IllegalArgumentException: wrong number of arguments
>> >> >> >
>> >> >> > groovy.lang.GroovyRuntimeException: failed to invoke constructor:
>> >> >> > public CustomUtilObject(groovy.util.ConfigObject) with arguments:
>> >> >> > []
>> >> >> > reason:
>> >> >> > java.lang.IllegalArgumentException: wrong number of arguments
>> >> >> >
>> >> >> > at MyScript.run(MyScript.groovy:16)
>> >> >> >
>> >> >> >
>> >> >> > I have tried to use "new CustomUtilObject(conf: conf)" as well,
>> >> >> > same
>> >> >> > error.
>> >> >> >
>> >> >> > The CustomUtilObject class in fact does have a single argument
>> >> >> > constructor:
>> >> >> >
>> >> >> >
>> >> >> >     CustomUtilObject(ConfigObject conf) {
>> >> >> >
>> >> >> >         this.conf = conf
>> >> >> >
>> >> >> >     }
>> >> >> >
>> >> >> >
>> >> >> > I'm at a complete loss as to why this is failing, and two days now
>> >> >> > have
>> >> >> > passed with no solution. Can anyone help? Thanks.
>> >> >> >
>> >> >> >
>> >> >> > Tom Harris
>> >> >> >
>> >> >> > Zemoga, Inc.
>> >> >> >
>> >> >> >
>> >> >>
>> >> >>
>> >> >> ---------------------------------------------------------------------
>> >> >> To unsubscribe from this list, please visit:
>> >> >>
>> >> >>    http://xircles.codehaus.org/manage_email
>> >> >>
>> >> >>
>> >> >
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe from this list, please visit:
>> >>
>> >>    http://xircles.codehaus.org/manage_email
>> >>
>> >>
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>

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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Problem running a Groovy script from within Eclipse

Andrew Eisenberg
Thanks for the test project, Tom.

I created https://jira.codehaus.org/browse/GRECLIPSE-1446

After 2.7.0 is released, I'll have a look at this.

On Thu, Jun 21, 2012 at 8:00 PM, Andrew Eisenberg <[hidden email]> wrote:

> I feel like there's something I'm not getting, or else there is a bug
> here.  If you can, you can send the project to me (not to the mailing
> list if there's proprietary code).  I can try to figure out what's
> going on.
>
> Getting the JDK source code on mac is a pain.  You need to download
> xcode and jump through about 10 more hoops.  But, the source code for
> Groovy is included in the groovy-eclipse distribution.
>
> On Thu, Jun 21, 2012 at 12:41 PM, Tom Harris <[hidden email]> wrote:
>>
>> The project does have a pom.xml in it, though I'm not using it. The
>> src/main/groovy source folder is defined, and so it should be part of the
>> build path. I tried turning on "Enable script folder support", but it didn't
>> help at all. I tried moving my script file into a new folder named "scripts"
>> in the project root, and setting one of the enabled script folders to be
>> that one, but nothing helped... I still keep getting this error.
>>
>> I tried to debug further, but the Mac version of the Java VM doesn't seem to
>> have the source code in it like its Windows counterparts. So, as soon as it
>> gets to line 16, it starts trying to run Class.forName() unknown source...
>> and I can no longer follow what its doing... It seems to play inside
>> String.class for a long time, some Groovy classes are shown in the stack as
>> well, but eventually, I get the same error tossed up without any reason.
>>
>> Tom
>>
>>
>> On Thu, Jun 21, 2012 at 3:31 PM, Andrew Eisenberg <[hidden email]>
>> wrote:
>>>
>>> > When I attempt to Run as... Java Appllcation, I just get a failure popup
>>> > that says 'Selection does not contain a main type'.
>>>
>>> That's odd.  Shouldn't be.  Scripts do have a main type.
>>>
>>> I take it that this is a maven project, then.  Are you using
>>> m2eclipse?  Is src/main/groovy on the build path (I'm guessing no,
>>> which would explain the lack of a main type)?  Are you using script
>>> folders (go to Preferences -> Groovy -> Compiler)?
>>>
>>>
>>> >
>>> > I attempted a few times to debug through to the failure, but it goes
>>> > pretty
>>> > deep into Unknown Source of groovy code and then fails before it ever
>>> > comes
>>> > back out to my script.
>>> >
>>> > I can navigate to the CustomUtilObject constructor using Fn+F3 (on my
>>> > Mac)
>>> > from the script line 16, with no issue.
>>> >
>>> > Thanks a lot for helping me out on this.
>>> >
>>> > Tom
>>> >
>>> > On Thu, Jun 21, 2012 at 2:36 PM, Andrew Eisenberg <[hidden email]>
>>> > wrote:
>>> >>
>>> >> So, CustomUtilObject is another script in the same project?
>>> >>
>>> >> You should be able to run your script as a Java app.  Just right-click
>>> >> -> Run as -> Java App.  There is a main method in the generated class
>>> >> file.  That is what is being used when you do run as java app.
>>> >>
>>> >> What happens when you set a breakpoint at line 16 and step into the
>>> >> code?  Can you see what class Groovy is trying to load?  What happens
>>> >> when you navigate to the class?
>>> >>
>>> >> On Thu, Jun 21, 2012 at 11:01 AM, Tom Harris <[hidden email]>
>>> >> wrote:
>>> >> >
>>> >> >
>>> >> > This is the latest groovy-eclipse-plugin
>>> >> > 2.6.1.xx-20120301-1000-e37-RELEASE,
>>> >> > with groovy compiler 1.8.6.xx-20120301-1000-e37-RELEASE.
>>> >> >
>>> >> > I'm not using anything from a command line, only from within Eclipse,
>>> >> > as
>>> >> > I
>>> >> > want to be able to debug through the script.
>>> >> >
>>> >> > CustomUtilObject is a custom groovy class that I'm using, which was
>>> >> > written
>>> >> > for use by another script. The other two developers on the team, who
>>> >> > originally wrote the CustomUtilObject class use only IntelliJ IDEA
>>> >> > IDE,
>>> >> > but
>>> >> > I've been an Eclipse user forever, and have no interest in
>>> >> > configuring
>>> >> > and
>>> >> > learning to use a commercial IDE.
>>> >> >
>>> >> > How would one go about running a groovy script as a Java app? That
>>> >> > doesn't
>>> >> > sound like an option to me, as there's no Java main method or
>>> >> > anything
>>> >> > in
>>> >> > the file.
>>> >> >
>>> >> > I'm pretty new to Groovy, been doing Java development since 1999.
>>> >> >
>>> >> > Tom Harris
>>> >> > Zemoga, Inc.
>>> >> >
>>> >> >
>>> >> > On Thu, Jun 21, 2012 at 1:43 PM, Andrew Eisenberg
>>> >> > <[hidden email]>
>>> >> > wrote:
>>> >> >>
>>> >> >> What version of groovy are you using?  Are you using the same
>>> >> >> version
>>> >> >> of groovy on the command line as in Eclipse?  Is CustomUtilObject
>>> >> >> one
>>> >> >> of your classes or is it a library class?
>>> >> >>
>>> >> >> Also, what happens if you try running as a java app?
>>> >> >>
>>> >> >> On Thu, Jun 21, 2012 at 9:41 AM, Tom Harris <[hidden email]>
>>> >> >> wrote:
>>> >> >> >
>>> >> >> > Groovy-Eclipse plugin developers:
>>> >> >> >
>>> >> >> > I have a pretty simple script I'm running, and I've been
>>> >> >> > struggling
>>> >> >> > to
>>> >> >> > get
>>> >> >> > it working for two days. Excerpt:
>>> >> >> >
>>> >> >> >
>>> >> >> > // some imports...
>>> >> >> >
>>> >> >> > line 13: CustomConfigUtil.setPropertyFilename(args[0])
>>> >> >> >
>>> >> >> > line 14: ConfigObject conf = CustomConfigUtil.getConf()
>>> >> >> >
>>> >> >> > line 15: Log.info("conf=${conf}") // prints happy things, so we
>>> >> >> > did
>>> >> >> > in
>>> >> >> > fact
>>> >> >> > load the config data
>>> >> >> >
>>> >> >> > line 16: CustomUtilObject customUtilObject =
>>> >> >> > new CustomUtilObject(conf)
>>> >> >> >
>>> >> >> > // etc...
>>> >> >> >
>>> >> >> >
>>> >> >> > When I attempt to run the script using the Run as... "Groovy
>>> >> >> > Script"
>>> >> >> > with
>>> >> >> > the appropriate parameters and such, I see the conf=${conf} Log
>>> >> >> > line
>>> >> >> > with
>>> >> >> > full data loaded, but then the error:
>>> >> >> >
>>> >> >> > Caught: groovy.lang.GroovyRuntimeException: failed to invoke
>>> >> >> > constructor:
>>> >> >> > public CustomUtilObject(groovy.util.ConfigObject) with arguments:
>>> >> >> > []
>>> >> >> > reason:
>>> >> >> > java.lang.IllegalArgumentException: wrong number of arguments
>>> >> >> >
>>> >> >> > groovy.lang.GroovyRuntimeException: failed to invoke constructor:
>>> >> >> > public CustomUtilObject(groovy.util.ConfigObject) with arguments:
>>> >> >> > []
>>> >> >> > reason:
>>> >> >> > java.lang.IllegalArgumentException: wrong number of arguments
>>> >> >> >
>>> >> >> > at MyScript.run(MyScript.groovy:16)
>>> >> >> >
>>> >> >> >
>>> >> >> > I have tried to use "new CustomUtilObject(conf: conf)" as well,
>>> >> >> > same
>>> >> >> > error.
>>> >> >> >
>>> >> >> > The CustomUtilObject class in fact does have a single argument
>>> >> >> > constructor:
>>> >> >> >
>>> >> >> >
>>> >> >> >     CustomUtilObject(ConfigObject conf) {
>>> >> >> >
>>> >> >> >         this.conf = conf
>>> >> >> >
>>> >> >> >     }
>>> >> >> >
>>> >> >> >
>>> >> >> > I'm at a complete loss as to why this is failing, and two days now
>>> >> >> > have
>>> >> >> > passed with no solution. Can anyone help? Thanks.
>>> >> >> >
>>> >> >> >
>>> >> >> > Tom Harris
>>> >> >> >
>>> >> >> > Zemoga, Inc.
>>> >> >> >
>>> >> >> >
>>> >> >>
>>> >> >>
>>> >> >> ---------------------------------------------------------------------
>>> >> >> To unsubscribe from this list, please visit:
>>> >> >>
>>> >> >>    http://xircles.codehaus.org/manage_email
>>> >> >>
>>> >> >>
>>> >> >
>>> >>
>>> >> ---------------------------------------------------------------------
>>> >> To unsubscribe from this list, please visit:
>>> >>
>>> >>    http://xircles.codehaus.org/manage_email
>>> >>
>>> >>
>>> >
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe from this list, please visit:
>>>
>>>    http://xircles.codehaus.org/manage_email
>>>
>>>
>>

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

    http://xircles.codehaus.org/manage_email