Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 1.1-beta-1
-
Fix Version/s: 1.1-beta-2
-
Component/s: None
-
Labels:None
-
Environment:Linux, Fedora
-
Number of attachments :
Description
given the file betabug.groovy:
def rloader = new javax.xml.namespace.QName("","").getClass().getClassLoader()
java.lang.Package[] pkgs = rloader.getPackages()
running the following shell script
export JAVA_HOME=/home/nate/java/jdk1.6.0
export GROOVY_HOME=/home/nate/java/groovy/groovy-1.1-BETA-1
export CLASSPATH=/home/nate/java/groovy/groovy-1.1-BETA-1/lib/groovy-1.1-BETA-1.jar
PATH=$PATH:$GROOVY_HOME/bin
/home/nate/java/groovy/groovy-1.1-BETA-1/bin/groovy -d /home/nate/CVSROOT/indivo-script/betabug.groovy
get the following exception:
Caught: java.lang.ClassCastException: gjdk.org.codehaus.groovy.tools.RootLoader_GroovyReflector cannot be cast to org.codehaus.groovy.runtime.Reflector
java.lang.ClassCastException: gjdk.org.codehaus.groovy.tools.RootLoader_GroovyReflector cannot be cast to org.codehaus.groovy.runtime.Reflector
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.loadReflector(MetaClassRegistryImpl.java:281)
at groovy.lang.MetaClassImpl.generateReflector(MetaClassImpl.java:2143)
at groovy.lang.MetaClassImpl.initialize(MetaClassImpl.java:2025)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.getMetaClass(MetaClassRegistryImpl.java:142)
at org.codehaus.groovy.runtime.Invoker.invokePojoMethod(Invoker.java:132)
at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:106)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:111)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:187)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethod0(ScriptBytecodeAdapter.java:211)
at betabug.run(betabug.groovy:2)
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:597)
at org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:616)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:506)
at org.codehaus.groovy.runtime.Invoker.invokePogoMethod(Invoker.java:144)
at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:110)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:111)
at org.codehaus.groovy.runtime.InvokerHelper.runScript(InvokerHelper.java:406)
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:597)
at org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:721)
at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:100)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:111)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:187)
at betabug.main(betabug.groovy)
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:597)
at org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:71)
at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:694)
at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:721)
at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:100)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:111)
at groovy.lang.GroovyShell.runMainOrTestOrRunnable(GroovyShell.java:270)
at groovy.lang.GroovyShell.run(GroovyShell.java:244)
at groovy.lang.GroovyShell.run(GroovyShell.java:173)
at groovy.ui.GroovyMain.processOnce(GroovyMain.java:484)
at groovy.ui.GroovyMain.run(GroovyMain.java:294)
at groovy.ui.GroovyMain.process(GroovyMain.java:280)
at groovy.ui.GroovyMain.processArgs(GroovyMain.java:140)
at groovy.ui.GroovyMain.main(GroovyMain.java:121)
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:597)
at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:131)
at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:160)
I am closing this because the bug is only partly related to Groovy. You have two versions of Groovy in your classpath. One is loaded by the rootloader, one is on the classpath. You should have only one version in the path or things like the mentioned ClassCastException is happening.So either do not use the $classpath variable or remove the groovy jar from the lib directory