Josh Juneau | 1 Sep 12:27 2004

Groovy SWT Tutorials

Has anyone tried to use Groovy SWT?  Are there any tutorials available for reference?  I tried to use the tutorial on the main Groovy site and the link did not function correctly.

 

I am a web designer looking to learn more about Swing, and the small amount of Groovy SWT code I’ve seen looks appealing.

 

Thanks-

 

Josh

jastrachan | 1 Sep 13:48 2004
Picon

Re: Problems with Maps

An easy fix to this problem is to force expansion of the GString to a 
String.

map.put("${foo}".toString(), value)

map.get("2")

as right now a GString is a different object instance to its static, 
constant, immutable String instance.

On 31 Aug 2004, at 17:24, John Wilson wrote:

>
> On 31 Aug 2004, at 17:03, NetBean wrote:
>
>>
>>
>> Hi, I have the following a snippet of
>> a program I am using to store and then
>> postprocess a Map of values...  but
>> the behaviour is not as expected
>> when I am retrieving the values using
>> the key.
>>
>>
>> ============= snippet ==============
>>
>> jlick = [:]     # init empty map
>> for ( i in 1..5) {
>>   k = "val is :${i}";
>>   jlick.put("${i}",k);
>> }
>> m = 2;
>>
>> ## I tried to use one of the following
>> ##   ways to get the value back using
>> ##   a key.
>>
>> #num = jlick.get("${m}");
>> #num = jlick.get("2");
>> #num = jlick.get(2);
>> #num = jlick.2;
>>
>> println("it is >${num}<");
>>
>> ============= snippet ==============
>>
>> Here's my results...
>>
>> # returns correct value
>> m = 2;
>> num = jlick.get("${m}");
>>
>> # returns null for num
>> #num = jlick.get("2");
>>
>
>
> this is a bug.
>
> println "${2}".hashCode() == "2".hashCode()
>
> prints
>
> false
>
> println "${2}" == "2"
>
> prints true
>
> The hashCodes should be identical.
>
> I'll raise an issue and fix it for you.
>
>
>
> John Wilson
> The Wilson Partnership
> http://www.wilson.co.uk
>
>

James
-------
http://radio.weblogs.com/0112098/

Dmitry Beransky | 2 Sep 02:35 2004

Re: database access

Any pointers anyone?  I'm absolutely stumped and have no idea where to 
proceed from here.

Dmitry

At 07:32 AM 8/31/2004, you wrote:
>Hi Kim,
>
>Yes, the actual script has the import line (I just forgot to include it
>in the email).
>
>
>Dmitry.
>
>On Tue, 31 Aug 2004 phkim@... wrote:
>
> > Hi, Dmitry
> >
> > Did you import groovy.sql.Sql ?
> >
> > import groovy.sql.Sql
> >
> >    Kim
> >
> > On Mon, Aug 30, 2004 at 10:49:42PM -0700, Dmitry Beransky wrote:
> > > Hi,
> > >
> > > I'm just starting off with Groovy, so forgive the trivial question, but I
> > > did search everywhere I could for an answer before posting.
> > >
> > > Here's my script:
> > >
> > > print "Hello World";
> > > sql = Sql.newInstance('jdbc:mysql://localhost/som_fiscal_dev',
> > > "som_user", "xxxxxx","org.gjt.mm.mysql.Driver");
> > >
> > > sql.eachRow("select * from role") {
> > >    println it.role_id;
> > > }
> > >
> > > very simple, but when I execute it I get "Hello World" and then 
> absolutely
> > > nothing: no output and no errors.  The database log shows the query being
> > > submitted, so I know that that part works.  The table is not emply, it
> > > contains 10 records.
> > >
> > > what am I missing?  I'm envoking this script via GroovyServlet
> > > runing under Tomcat 5.0 using Groovy 1.0-beta6 libraries.
> > >
> > >
> > > Thanks
> > > Dmitry
> >

Josh Juneau | 2 Sep 04:01 2004

FW: database access

Dmitry-

After investigation of your script, I think I see the error.  Try writing
your query be as follows:

Sql.eachRow("select * from role") {println("${it.role_id}")
}

I think you are missing the ${} syntax around the column name.

Hope this does the trick-
Josh

-----Original Message-----
From: Dmitry Beransky [mailto:db01@...] 
Sent: Wednesday, September 01, 2004 7:36 PM
To: user@...
Subject: Re: [groovy-user] database access

Any pointers anyone?  I'm absolutely stumped and have no idea where to 
proceed from here.

Dmitry

At 07:32 AM 8/31/2004, you wrote:
>Hi Kim,
>
>Yes, the actual script has the import line (I just forgot to include it
>in the email).
>
>
>Dmitry.
>
>On Tue, 31 Aug 2004 phkim@... wrote:
>
> > Hi, Dmitry
> >
> > Did you import groovy.sql.Sql ?
> >
> > import groovy.sql.Sql
> >
> >    Kim
> >
> > On Mon, Aug 30, 2004 at 10:49:42PM -0700, Dmitry Beransky wrote:
> > > Hi,
> > >
> > > I'm just starting off with Groovy, so forgive the trivial question,
but I
> > > did search everywhere I could for an answer before posting.
> > >
> > > Here's my script:
> > >
> > > print "Hello World";
> > > sql = Sql.newInstance('jdbc:mysql://localhost/som_fiscal_dev',
> > > "som_user", "xxxxxx","org.gjt.mm.mysql.Driver");
> > >
> > > sql.eachRow("select * from role") {
> > >    println it.role_id;
> > > }
> > >
> > > very simple, but when I execute it I get "Hello World" and then 
> absolutely
> > > nothing: no output and no errors.  The database log shows the query
being
> > > submitted, so I know that that part works.  The table is not emply, it
> > > contains 10 records.
> > >
> > > what am I missing?  I'm envoking this script via GroovyServlet
> > > runing under Tomcat 5.0 using Groovy 1.0-beta6 libraries.
> > >
> > >
> > > Thanks
> > > Dmitry
> >

Sean Radford | 2 Sep 10:55 2004
Picon

Ant filtersfile

Hi,

I've only just started using Groovy (beta-6) and have been looking at 
some Ant work with it, but have hit the following problem and wondered 
if anyone can spot what I'm doing wrong:

The following code:

ant.sequential {
  copy(file: mySrcFile, tofile: myDestFile, filtering: true) {
    filterset(begintoken:" <at>  <at> ", endtoken:" <at>  <at> ") {
      filtersfile(file:"build.properties")
    }
  }
}

produces (on compilation):

groovy.lang.MissingClassException: No such class: Configuration in 
constructor call for class: Main. At [71:19] 
/home/sradford/data/aegeus/projects/intercert/intercertauth-builder/./JbossIntercertAuthBuilder
        at 
org.codehaus.groovy.classgen.AsmClassGenerator2.checkValidType(AsmClassGenerator2.java:4670)
        at 
org.codehaus.groovy.classgen.AsmClassGenerator2.visitConstructorCallExpression(AsmClassGenerator2.java:2255)
        at 
org.codehaus.groovy.ast.expr.ConstructorCallExpression.visit(ConstructorCallExpression.java:91)
        at 
org.codehaus.groovy.classgen.AsmClassGenerator2.visitAndAutoboxBoolean(AsmClassGenerator2.java:4094)
        at 
org.codehaus.groovy.classgen.AsmClassGenerator2.evaluateEqual(AsmClassGenerator2.java:3945)
        at 
org.codehaus.groovy.classgen.AsmClassGenerator2.visitBinaryExpression(AsmClassGenerator2.java:1145)
        at 
org.codehaus.groovy.ast.expr.BinaryExpression.visit(BinaryExpression.java:335)
        at 
org.codehaus.groovy.classgen.AsmClassGenerator2.visitAndAutoboxBoolean(AsmClassGenerator2.java:4094)
        at 
org.codehaus.groovy.classgen.AsmClassGenerator2.visitExpressionStatement(AsmClassGenerator2.java:1131)
        at 
org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:70)
        at 
org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:108)
        at 
org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:79)
        at 
org.codehaus.groovy.classgen.AsmClassGenerator2.visitMethod(AsmClassGenerator2.java:404)
        at 
org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:786)
        at 
org.codehaus.groovy.classgen.AsmClassGenerator2.visitClass(AsmClassGenerator2.java:306)
        at 
org.codehaus.groovy.control.CompilationUnit$5.call(CompilationUnit.java:579)
        at 
org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:844)
        at 
org.codehaus.groovy.control.CompilationUnit.classgen(CompilationUnit.java:540)
        at 
org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:446)
        at 
groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:244)
        at 
groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:163)
        at groovy.lang.GroovyShell$2.run(GroovyShell.java:216)
        at java.security.AccessController.doPrivileged(Native Method)
        at groovy.lang.GroovyShell.run(GroovyShell.java:214)
        at groovy.lang.GroovyShell.run(GroovyShell.java:161)
        at groovy.ui.GroovyMain.processOnce(GroovyMain.java:335)
        at groovy.ui.GroovyMain.run(GroovyMain.java:215)
        at groovy.ui.GroovyMain.process(GroovyMain.java:200)
        at groovy.ui.GroovyMain.main(GroovyMain.java:119)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at 
org.codehaus.classworlds.Launcher.launchStandard(Launcher.java:410)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:344)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:461)
Caught: General error during class generation: No such class: 
Configuration in constructor call for class: Main. At [71:19] 
/home/sradford/data/aegeus/projects/intercert/intercertauth-builder/./JbossIntercertAuthBuilder
        at 
org.codehaus.groovy.control.ProcessingUnit.fail(ProcessingUnit.java:466)
        at 
org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:867)
        at 
org.codehaus.groovy.control.CompilationUnit.classgen(CompilationUnit.java:540)
        at 
org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:446)
        at 
groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:244)
        at 
groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:163)
        at groovy.lang.GroovyShell$2.run(GroovyShell.java:216)
        at java.security.AccessController.doPrivileged(Native Method)
        at groovy.lang.GroovyShell.run(GroovyShell.java:214)
        at groovy.lang.GroovyShell.run(GroovyShell.java:161)
        at groovy.ui.GroovyMain.processOnce(GroovyMain.java:335)
        at groovy.ui.GroovyMain.run(GroovyMain.java:215)
        at groovy.ui.GroovyMain.process(GroovyMain.java:200)
        at groovy.ui.GroovyMain.main(GroovyMain.java:119)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at 
org.codehaus.classworlds.Launcher.launchStandard(Launcher.java:410)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:344)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:461)

If I remove the 'filtersfile' then it compiles, so looks like it is the 
constructor of that...

Any ideas / workarounds?

Thanks,

Sean

--

-- 
Dr. Sean Radford, MBBS, MSc
sradford@...
http://bladesys.demon.co.uk/ 

jastrachan | 2 Sep 11:13 2004
Picon

Re: Ant filtersfile


On 2 Sep 2004, at 09:55, Sean Radford wrote:
> groovy.lang.MissingClassException: No such class: Configuration in  
> constructor call for class: Main. At [71:19]  
> /home/sradford/data/aegeus/projects/intercert/intercertauth-builder/./ 
> JbossIntercertAuthBuilder
>

I've no idea what the 'filtersfile' ant task is - any ideas? Its  
certainly not a core task AFAIK

http://ant.apache.org/manual/coretasklist.html

Also I've no idea what the Configuration class is used in the  
configuration of this Ant task - but it sounds like a classpath issue  
for your use of the filtersfile task.

James
-------
http://radio.weblogs.com/0112098/

jastrachan | 2 Sep 11:16 2004
Picon

Re: database access

I don't think that will have made any difference - it should work just 
as well without the "${...}" wrapper

I wonder if the it.role_id is a blank string? So try adding more 
debugging just in case

println "Start"
Sql.eachRow("select * from role") {
  println "RoleID is ${it.role_id}"
}
println "End"

and surely something must appear

On 2 Sep 2004, at 03:01, Josh Juneau wrote:

> Dmitry-
>
> After investigation of your script, I think I see the error.  Try 
> writing
> your query be as follows:
>
> Sql.eachRow("select * from role") {println("${it.role_id}")
> }
>
> I think you are missing the ${} syntax around the column name.
>
> Hope this does the trick-
> Josh
>
> -----Original Message-----
> From: Dmitry Beransky [mailto:db01@...]
> Sent: Wednesday, September 01, 2004 7:36 PM
> To: user@...
> Subject: Re: [groovy-user] database access
>
> Any pointers anyone?  I'm absolutely stumped and have no idea where to
> proceed from here.
>
> Dmitry
>
> At 07:32 AM 8/31/2004, you wrote:
>> Hi Kim,
>>
>> Yes, the actual script has the import line (I just forgot to include 
>> it
>> in the email).
>>
>>
>> Dmitry.
>>
>> On Tue, 31 Aug 2004 phkim@... wrote:
>>
>>> Hi, Dmitry
>>>
>>> Did you import groovy.sql.Sql ?
>>>
>>> import groovy.sql.Sql
>>>
>>>    Kim
>>>
>>> On Mon, Aug 30, 2004 at 10:49:42PM -0700, Dmitry Beransky wrote:
>>>> Hi,
>>>>
>>>> I'm just starting off with Groovy, so forgive the trivial question,
> but I
>>>> did search everywhere I could for an answer before posting.
>>>>
>>>> Here's my script:
>>>>
>>>> print "Hello World";
>>>> sql = Sql.newInstance('jdbc:mysql://localhost/som_fiscal_dev',
>>>> "som_user", "xxxxxx","org.gjt.mm.mysql.Driver");
>>>>
>>>> sql.eachRow("select * from role") {
>>>>    println it.role_id;
>>>> }
>>>>
>>>> very simple, but when I execute it I get "Hello World" and then
>> absolutely
>>>> nothing: no output and no errors.  The database log shows the query
> being
>>>> submitted, so I know that that part works.  The table is not emply, 
>>>> it
>>>> contains 10 records.
>>>>
>>>> what am I missing?  I'm envoking this script via GroovyServlet
>>>> runing under Tomcat 5.0 using Groovy 1.0-beta6 libraries.
>>>>
>>>>
>>>> Thanks
>>>> Dmitry
>>>
>
>
>

James
-------
http://radio.weblogs.com/0112098/

Sean Radford | 2 Sep 12:05 2004
Picon

Re: Ant filtersfile

jastrachan@... wrote:

>
> On 2 Sep 2004, at 09:55, Sean Radford wrote:
>
>> groovy.lang.MissingClassException: No such class: Configuration in  
>> constructor call for class: Main. At [71:19]  
>> /home/sradford/data/aegeus/projects/intercert/intercertauth-builder/./ 
>> JbossIntercertAuthBuilder
>>
>
> I've no idea what the 'filtersfile' ant task is - any ideas? Its  
> certainly not a core task AFAIK
>
> http://ant.apache.org/manual/coretasklist.html
>
> Also I've no idea what the Configuration class is used in the  
> configuration of this Ant task - but it sounds like a classpath issue  
> for your use of the filtersfile task.
>
> James
> -------
> http://radio.weblogs.com/0112098/
>
>
Sorry - I made a mistake and attached an incorrect stack trace....

I was using beta-4 and got my problem with filterfile (this is not an 
Ant task, but a core type: 
http://ant.apache.org/manual/CoreTypes/filterset.html).

I then upgraded to beta-6 and got the stack trace I posted (I didn't 
look at it closely enough to note it wasn't the same)!!

So now I have upgraded to beta-6 and can't even run any scripts!

#!/usr/bin/env groovy
println("hello")

produces:

Exception in thread "main" java.lang.ClassFormatError:  (Illegal Class 
name "")
        at java.lang.ClassLoader.defineClass0(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:537)
        at 
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
        at 
groovy.lang.GroovyClassLoader.access$100(GroovyClassLoader.java:81)
        at 
groovy.lang.GroovyClassLoader$ClassCollector.onClassNode(GroovyClassLoader.java:505)
        at 
groovy.lang.GroovyClassLoader$ClassCollector.call(GroovyClassLoader.java:515)
        at 
org.codehaus.groovy.control.CompilationUnit$5.call(CompilationUnit.java:604)
        at 
org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:844)
        at 
org.codehaus.groovy.control.CompilationUnit.classgen(CompilationUnit.java:540)
        at 
org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:446)
        at 
groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:244)
        at 
groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:163)
        at groovy.lang.GroovyShell$2.run(GroovyShell.java:216)
        at java.security.AccessController.doPrivileged(Native Method)
        at groovy.lang.GroovyShell.run(GroovyShell.java:214)
        at groovy.lang.GroovyShell.run(GroovyShell.java:161)
        at groovy.ui.GroovyMain.processOnce(GroovyMain.java:335)
        at groovy.ui.GroovyMain.run(GroovyMain.java:215)
        at groovy.ui.GroovyMain.process(GroovyMain.java:200)
        at groovy.ui.GroovyMain.main(GroovyMain.java:119)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at 
org.codehaus.classworlds.Launcher.launchStandard(Launcher.java:410)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:344)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:461)

(However, if I convert my script using 'groovy shell command' and not 
the '#!/usr/bin/env groovy' mechanism my filtersfile works. So I'm happy 
I guess.)

--

-- 
Dr. Sean Radford, MBBS, MSc
sradford@...
http://bladesys.demon.co.uk/ 

Daniel Serodio | 2 Sep 16:17 2004
Picon

Re: database access

Try

sql.eachRow("select * from role") { println it }

or

sql.eachRow("select count(*) from role") { println it }

[]'s
Daniel Serodio

Dmitry Beransky wrote:

> Any pointers anyone?  I'm absolutely stumped and have no idea where to 
> proceed from here.
>
> Dmitry
>
> At 07:32 AM 8/31/2004, you wrote:
>
>> Hi Kim,
>>
>> Yes, the actual script has the import line (I just forgot to include it
>> in the email).
>>
>>
>> Dmitry.
>>
>> On Tue, 31 Aug 2004 phkim@... wrote:
>>
>> > Hi, Dmitry
>> >
>> > Did you import groovy.sql.Sql ?
>> >
>> > import groovy.sql.Sql
>> >
>> >    Kim
>> >
>> > On Mon, Aug 30, 2004 at 10:49:42PM -0700, Dmitry Beransky wrote:
>> > > Hi,
>> > >
>> > > I'm just starting off with Groovy, so forgive the trivial 
>> question, but I
>> > > did search everywhere I could for an answer before posting.
>> > >
>> > > Here's my script:
>> > >
>> > > print "Hello World";
>> > > sql = Sql.newInstance('jdbc:mysql://localhost/som_fiscal_dev',
>> > > "som_user", "xxxxxx","org.gjt.mm.mysql.Driver");
>> > >
>> > > sql.eachRow("select * from role") {
>> > >    println it.role_id;
>> > > }
>> > >
>> > > very simple, but when I execute it I get "Hello World" and then 
>> absolutely
>> > > nothing: no output and no errors.  The database log shows the 
>> query being
>> > > submitted, so I know that that part works.  The table is not 
>> emply, it
>> > > contains 10 records.
>> > >
>> > > what am I missing?  I'm envoking this script via GroovyServlet
>> > > runing under Tomcat 5.0 using Groovy 1.0-beta6 libraries.
>> > >
>> > >
>> > > Thanks
>> > > Dmitry
>> >
>

jastrachan | 2 Sep 16:56 2004
Picon

Re: Ant filtersfile


On 2 Sep 2004, at 11:05, Sean Radford wrote:

> So now I have upgraded to beta-6 and can't even run any scripts!
>
> #!/usr/bin/env groovy
> println("hello")
>
> produces:
>
> Exception in thread "main" java.lang.ClassFormatError:  (Illegal Class 
> name "")
>        at java.lang.ClassLoader.defineClass0(Native Method)

What file name did you use for this script?

James
-------
http://radio.weblogs.com/0112098/


Gmane