org.codehaus.groovy.runtime.typehandling.GroovyCastException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • When running the following sample in Groovy Console, with "allow interruption" checked: {code} @Grab('com.netflix.rxjava:rxjava-groovy:0.18.1') import groovy.transform.CompileStatic import org.junit.Test import rx.Observable @CompileStatic class Test1 { @Test void test1() { Observable.from(["mark", "perry"]).subscribe({ println("item: $it") }) } } {code} I get the following stacktrace: {code} JUnit 4 Runner, Tests: 1, Failures: 1, Time: 8 Test Failure: test1(Test1) rx.exceptions.OnErrorNotImplementedException: Cannot cast object 'Test1@4b7d52f7' with class 'Test1' to class 'java.lang.Thread' at rx.Observable$26.onError(Observable.java:6015) at rx.observers.SafeSubscriber._onError(SafeSubscriber.java:125) at rx.observers.SafeSubscriber.onError(SafeSubscriber.java:94) at rx.observers.SafeSubscriber.onNext(SafeSubscriber.java:109) at rx.operators.OnSubscribeFromIterable.call(OnSubscribeFromIterable.java:43) at rx.operators.OnSubscribeFromIterable.call(OnSubscribeFromIterable.java:29) at rx.Observable.subscribe(Observable.java:6302) at rx.Observable.subscribe(Observable.java:6006) at Test1.test1(ConsoleScript35:13) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) at org.junit.runners.ParentRunner.run(ParentRunner.java:309) at org.junit.runners.Suite.runChild(Suite.java:127) at org.junit.runners.Suite.runChild(Suite.java:26) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) at org.junit.runners.ParentRunner.run(ParentRunner.java:309) at org.junit.runner.JUnitCore.run(JUnitCore.java:160) at org.junit.runner.JUnitCore.run(JUnitCore.java:138) at org.junit.runner.JUnitCore.run(JUnitCore.java:128) at org.junit.runner.JUnitCore.runClasses(JUnitCore.java:73) at sun.reflect.GeneratedMethodAccessor304.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233) at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1318) at org.codehaus.groovy.runtime.InvokerHelper.invokeStaticMethod(InvokerHelper.java:927) at org.codehaus.groovy.vmplugin.v5.JUnit4Utils.realRunJUnit4Test(JUnit4Utils.java:84) at sun.reflect.GeneratedMethodAccessor303.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233) at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1318) at org.codehaus.groovy.runtime.InvokerHelper.invokeStaticMethod(InvokerHelper.java:927) at org.codehaus.groovy.runtime.InvokerHelper.invokeStaticMethod(InvokerHelper.java:77) at groovy.lang.GroovyShell.runJUnit4Test(GroovyShell.java:378) at groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:281) at groovy.lang.GroovyShell.run(GroovyShell.java:502) at groovy.lang.GroovyShell.run(GroovyShell.java:481) at groovy.lang.GroovyShell.run(GroovyShell.java:164) at groovy.lang.GroovyShell$run$1.call(Unknown Source) at groovy.ui.Console$_runScriptImpl_closure17.doCall(Console.groovy:977) at groovy.ui.Console$_runScriptImpl_closure17.doCall(Console.groovy) at sun.reflect.GeneratedMethodAccessor288.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233) at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:909) at groovy.lang.Closure.call(Closure.java:423) at groovy.lang.Closure.call(Closure.java:417) at groovy.lang.Closure.run(Closure.java:504) at java.lang.Thread.run(Thread.java:745) Caused by: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'Test1@4b7d52f7' with class 'Test1' to class 'java.lang.Thread' at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnSAM(DefaultTypeTransformation.java:392) at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnNumber(DefaultTypeTransformation.java:306) at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:227) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.castToType(ScriptBytecodeAdapter.java:599) at Test1$_test1_closure1.doCall(ConsoleScript35) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233) at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:909) at groovy.lang.Closure.call(Closure.java:423) at org.codehaus.groovy.runtime.ConvertedClosure.invokeCustom(ConvertedClosure.java:51) at org.codehaus.groovy.runtime.ConversionHandler.invoke(ConversionHandler.java:81) at com.sun.proxy.$Proxy16.call(Unknown Source) at rx.Observable$26.onNext(Observable.java:6020) at rx.observers.SafeSubscriber.onNext(SafeSubscriber.java:102) ... 69 more Result: org.junit.runner.Result@5e359fba {code} Which seems to be a problem with thread interruption and static compilation.
    via by Guillaume Delcroix,
  • Why is this Groovy code trying to cast?
    via Stack Overflow by tinny
    ,
  • groovy "with" block usage query
    via Stack Overflow by Abe
    ,
    • org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'sun.awt.image.MultiResolutionCachedImage@28c15eb4' with class 'sun.awt.image.MultiResolutionCachedImage' to class 'java.awt.image.BufferedImage' at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnSAM(DefaultTypeTransformation.java:392) at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnNumber(DefaultTypeTransformation.java:306) at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:227) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.castToType(ScriptBytecodeAdapter.java:599) at insertInlineImage$_run_closure7_closure12_closure15_closure27.doCall(insertInlineImage.groovy:278) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233) at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:909) at groovy.lang.Closure.call(Closure.java:423) at org.codehaus.groovy.runtime.ConvertedClosure.invokeCustom(ConvertedClosure.java:51) at org.codehaus.groovy.runtime.ConversionHandler.invoke(ConversionHandler.java:81) at com.sun.proxy.$Proxy14.actionPerformed(Unknown Source) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022) at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252) at java.awt.Component.processMouseEvent(Component.java:6535) at javax.swing.JComponent.processMouseEvent(JComponent.java:3324) at java.awt.Component.processEvent(Component.java:6300) at java.awt.Container.processEvent(Container.java:2236) at java.awt.Component.dispatchEventImpl(Component.java:4891) at java.awt.Container.dispatchEventImpl(Container.java:2294) at java.awt.Component.dispatchEvent(Component.java:4713) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4525) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466) at java.awt.Container.dispatchEventImpl(Container.java:2280) at java.awt.Window.dispatchEventImpl(Window.java:2750) at java.awt.Component.dispatchEvent(Component.java:4713) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758) at java.awt.EventQueue.access$500(EventQueue.java:97) at java.awt.EventQueue$3.run(EventQueue.java:709) at java.awt.EventQueue$3.run(EventQueue.java:703) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86) at java.awt.EventQueue$4.run(EventQueue.java:731) at java.awt.EventQueue$4.run(EventQueue.java:729) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76) at java.awt.EventQueue.dispatchEvent(EventQueue.java:728) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:109) at java.awt.WaitDispatchSupport$2.run(WaitDispatchSupport.java:184) at java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:229) at java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:227) at java.security.AccessController.doPrivileged(Native Method) at java.awt.WaitDispatchSupport.enter(WaitDispatchSupport.java:227) at java.awt.Dialog.show(Dialog.java:1084) at java.awt.Component.show(Component.java:1673) at java.awt.Component.setVisible(Component.java:1625) at java.awt.Window.setVisible(Window.java:1014) at java.awt.Dialog.setVisible(Dialog.java:1005) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233) at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:2526) at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:3462) at org.codehaus.groovy.runtime.InvokerHelper.setProperty(InvokerHelper.java:195) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.setProperty(ScriptBytecodeAdapter.java:480) at insertInlineImage.run(insertInlineImage.groovy:660) at org.freeplane.plugin.script.GroovyScript.execute(GroovyScript.java:133) at org.freeplane.plugin.script.ExecuteScriptAction.actionPerformed(ExecuteScriptAction.java:92) at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1663) at org.freeplane.core.ui.ActionAcceleratorManager.processKeyBinding(ActionAcceleratorManager.java:402) at org.freeplane.main.mindmapmode.MModeControllerFactory$2.processKeyBinding(MModeControllerFactory.java:278) at org.freeplane.view.swing.ui.UserInputListenerFactory$2.processKeyBinding(UserInputListenerFactory.java:117) at org.freeplane.core.ui.components.FreeplaneMenuBar.processKeyBinding(FreeplaneMenuBar.java:91) at org.freeplane.main.application.MenuKeyProcessor.processKeyBinding(MenuKeyProcessor.java:26) at org.freeplane.main.application.ConnectedToMenuView.processKeyBinding(ConnectedToMenuView.java:41) at javax.swing.JComponent.processKeyBindings(JComponent.java:2943) at javax.swing.JComponent.processKeyEvent(JComponent.java:2845) at java.awt.Component.processEvent(Component.java:6312) at java.awt.Container.processEvent(Container.java:2236) at java.awt.Component.dispatchEventImpl(Component.java:4891) at java.awt.Container.dispatchEventImpl(Container.java:2294) at java.awt.Component.dispatchEvent(Component.java:4713) at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1954) at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:806) at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1074) at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:945) at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:771) at java.awt.Component.dispatchEventImpl(Component.java:4762) at java.awt.Container.dispatchEventImpl(Container.java:2294) at java.awt.Window.dispatchEventImpl(Window.java:2750) at java.awt.Component.dispatchEvent(Component.java:4713) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758) at java.awt.EventQueue.access$500(EventQueue.java:97) at java.awt.EventQueue$3.run(EventQueue.java:709) at java.awt.EventQueue$3.run(EventQueue.java:703) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86) at java.awt.EventQueue$4.run(EventQueue.java:731) at java.awt.EventQueue$4.run(EventQueue.java:729) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76) at java.awt.EventQueue.dispatchEvent(EventQueue.java:728) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

    Users with the same issue

    stigkj
    1 times, last one,
    musketyr
    11 times, last one,
    derprogger
    1 times, last one,
    johnxfly
    2 times, last one,
    jesse
    2 times, last one,
    15 more bugmates