[groovy-user] Simple Groovy SQL script fails moving from 2.2.2 to 2.3.8

15 views
Skip to first unread message

KARR, DAVID

unread,
Jan 13, 2015, 12:50:01 PM1/13/15
to Groovy User
I have a simple Groovy SQL script that I've been using with Groovy 2.2.2 for quite a while. I just upgraded to 2.3.8 and now it fails with "java.net.MalformedURLException: unknown protocol: c". I verified that moving back to 2.2.2 makes it work again. What might be happening here?

With some elision ("<>" blocks), here is the script:
-----------------------
#! env groovy
import groovy.sql.Sql
if (args.length < 1) {
println "Usage: usergroups loginname"
System.exit(1)
}

def login = args[0];
def List list = new ArrayList();
sql = Sql.newInstance('jdbc:oracle:thin:@<hostname>:1521:<SID>',
'<user>', '<password>', 'oracle.jdbc.driver.OracleDriver')
sql.eachRow("select gd.GRPDSCRPTN_TITLE title from GRPDSCRPTN gd join GROUPUSERS gu on gu.GROUPUSERS_GROUPID = gd.GRPDSCRPTN_ID join USER_VIEW u on u.ID = gu.GROUPUSERS_USERID where u.login = '" + login + "' order by title")
{
list.add(it.title);
}

println("Groups for user \"" + login + "\":");
for (int ctr = 0; ctr < list.size(); ++ ctr) {
println(list.get(ctr));
}
if (list.size() == 0) {
println("No groups found for user \"" + login + "\".");
}
--------------------

Note that I manually installed the oracle "ojdbc6.jar", and this is wrapped by a bash script that calls Groovy with a "-cp" parameter pointing to that jar file.

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

http://xircles.codehaus.org/manage_email


Pascal Schumacher

unread,
Jan 13, 2015, 1:31:40 PM1/13/15
to us...@groovy.codehaus.org
Hello David,
 
can you send the full stacktrace?
 
It's just a shot in the dark, but the problem you are facing may be related to: https://jira.codehaus.org/browse/GROOVY-7018
 
-Pascal
Gesendet: Dienstag, 13. Januar 2015 um 18:48 Uhr
Von: "KARR, DAVID" <dk0...@att.com>
An: "Groovy User" <us...@groovy.codehaus.org>
Betreff: [groovy-user] Simple Groovy SQL script fails moving from 2.2.2 to 2.3.8

KARR, DAVID

unread,
Jan 13, 2015, 2:12:40 PM1/13/15
to us...@groovy.codehaus.org

Here ‘tis:

Caught: java.net.MalformedURLException: unknown protocol: c

java.net.MalformedURLException: unknown protocol: c

        at java.net.URL.<init>(URL.java:592)

        at java.net.URL.<init>(URL.java:482)

        at java.net.URL.<init>(URL.java:431)

        at java.net.URI.toURL(URI.java:1096)

        at groovy.lang.GroovyCodeSource.<init>(GroovyCodeSource.java:162)

        at groovy.ui.GroovyMain.getScriptSource(GroovyMain.java:450)

        at groovy.ui.GroovyMain.processOnce(GroovyMain.java:650)

        at groovy.ui.GroovyMain.run(GroovyMain.java:381)

        at groovy.ui.GroovyMain.process(GroovyMain.java:367)

        at groovy.ui.GroovyMain.processArgs(GroovyMain.java:126)

        at groovy.ui.GroovyMain.main(GroovyMain.java:106)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

        at java.lang.reflect.Method.invoke(Method.java:606)

        at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:106)

        at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:128)

---------------------------------

KARR, DAVID

unread,
Jan 13, 2015, 5:34:51 PM1/13/15
to us...@groovy.codehaus.org


> -----Original Message-----
> From: KARR, DAVID
> Sent: Tuesday, January 13, 2015 9:48 AM
> To: Groovy User
> Subject: [groovy-user] Simple Groovy SQL script fails moving from 2.2.2 to
> 2.3.8
>
I think this problem may be relevant: http://stackoverflow.com/questions/24303057/groovy-scripts-no-longer-work-under-cygwin .

I didn't mention I was using Cygwin, because I thought the script was failing within the Groovy code, but I think that's not the case.

KARR, DAVID

unread,
Jan 13, 2015, 5:55:43 PM1/13/15
to us...@groovy.codehaus.org
Whoa. Now I'm really confused. I managed to get this working using the following command line in my wrapper script:

groovy -cp "$(cygpath -w ~/frameworks/ojdbc6/ojdbc6.jar)" "$(cygpath -w ~/bin/lastactivity.groovy)" "$@"

Curiously, I found that I can change the "-w" to "-m" in the classpath value, but not in the path to the Groovy script to execute. In Groovy 2.2.2, both of these can be "-m". I believe that SO link talks about some of this.

The other oddity is that if I change this line to:

groovy --debug -cp "$(cygpath -w ~/frameworks/ojdbc6/ojdbc6.jar)" "$(cygpath -w ~/bin/lastactivity.groovy)" "$@"

Then it fails with this:

java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver

The "--debug" (or "-d") option is just supposed to print full stacktraces. It seemed like it corrupted the resulting command line to the JVM.
Reply all
Reply to author
Forward
0 new messages