java.lang.IllegalArgumentException: object is not an instance of declaring class

Apache's JIRA Issue Tracker | Martin Mavrov | 9 years ago
  1. 0

    [GROOVY-2583] "object is not an instance of declaring class" thrown invoking a method on Groovy class, wrapped in a Spring proxy - ASF JIRA

    apache.org | 1 year ago
    java.lang.IllegalArgumentException: object is not an instance of declaring class
  2. 0

    [GROOVY-2583] "object is not an instance of declaring class" thrown invoking a method on Groovy class, wrapped in a Spring proxy - ASF JIRA

    apache.org | 12 months ago
    java.lang.IllegalArgumentException: object is not an instance of declaring class
  3. 0

    I suspect this is connected with GROOVY-2006, here is the case: I have two Spring-loaded groovy scripts, marked with refresh-check-delay, which loads them as CGLIB proxies. Invoking a method on the proxy instance, I get {code:none} Exception in thread "main" java.lang.IllegalArgumentException: object is not an instance of declaring class at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:899) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:740) at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:777) at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:757) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:167) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethod0(ScriptBytecodeAdapter.java:195) at X.doIt(script1.groovy]:5) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:301) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149) at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131) at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at $Proxy1.doIt(Unknown Source) at TestMe.main(TestMe.java:20) {code} {code:title=script1.groovy} class X implements Doable { def prop void doIt() { println prop.getClass().getName(); prop.doIt(); } } {code} {code:title=script2.groovy} class Y { void doIt() { println "OK"; } } {code} {code:title=Doable.java} public interface Doable { void doIt(); } {code} {code:xml|title=spring.xml} <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:lang="http://www.springframework.org/schema/lang" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd"> <lang:groovy id="y" script-source="classpath:groovy/script2.groovy" refresh-check-delay="1000"/> <lang:groovy id="x" script-source="classpath:groovy/script1.groovy" refresh-check-delay="1000"> <lang:property name="prop" ref="y"/> </lang:groovy> </beans> {code} {code:title=TestMe.java} import org.springframework.context.support.ClassPathXmlApplicationContext; public class TestMe { public static void main(String[] args) { ClassPathXmlApplicationContext ctxt = new ClassPathXmlApplicationContext("spring.xml"); Doable o = (Doable)ctxt.getBean("x"); o.doIt(); } } {code}

    Apache's JIRA Issue Tracker | 9 years ago | Martin Mavrov
    java.lang.IllegalArgumentException: object is not an instance of declaring class
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    I suspect this is connected with GROOVY-2006, here is the case: I have two Spring-loaded groovy scripts, marked with refresh-check-delay, which loads them as CGLIB proxies. Invoking a method on the proxy instance, I get {code:none} Exception in thread "main" java.lang.IllegalArgumentException: object is not an instance of declaring class at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:899) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:740) at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:777) at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:757) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:167) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethod0(ScriptBytecodeAdapter.java:195) at X.doIt(script1.groovy]:5) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:301) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149) at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131) at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at $Proxy1.doIt(Unknown Source) at TestMe.main(TestMe.java:20) {code} {code:title=script1.groovy} class X implements Doable { def prop void doIt() { println prop.getClass().getName(); prop.doIt(); } } {code} {code:title=script2.groovy} class Y { void doIt() { println "OK"; } } {code} {code:title=Doable.java} public interface Doable { void doIt(); } {code} {code:xml|title=spring.xml} <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:lang="http://www.springframework.org/schema/lang" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.xsd"> <lang:groovy id="y" script-source="classpath:groovy/script2.groovy" refresh-check-delay="1000"/> <lang:groovy id="x" script-source="classpath:groovy/script1.groovy" refresh-check-delay="1000"> <lang:property name="prop" ref="y"/> </lang:groovy> </beans> {code} {code:title=TestMe.java} import org.springframework.context.support.ClassPathXmlApplicationContext; public class TestMe { public static void main(String[] args) { ClassPathXmlApplicationContext ctxt = new ClassPathXmlApplicationContext("spring.xml"); Doable o = (Doable)ctxt.getBean("x"); o.doIt(); } } {code}

    Apache's JIRA Issue Tracker | 9 years ago | Martin Mavrov
    java.lang.IllegalArgumentException: object is not an instance of declaring class
  6. 0

    [groovy-user] Method-Calls 1.0 vs. 1.5

    Google Groups | 9 years ago | Thorsten Kamann
    java.lang.IllegalArgumentException

  1. Aria Pahlavan 16 times, last 2 weeks ago
  2. kjhdofjosvs 2 times, last 1 month ago
  3. tyson925 2 times, last 1 month ago
  4. kuldeep 2 times, last 2 months ago
  5. aldrinleal 1 times, last 5 months ago
6 more registered users
72 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.lang.IllegalArgumentException

    object is not an instance of declaring class

    at sun.reflect.NativeMethodAccessorImpl.invoke0()
  2. Java RT
    Method.invoke
    1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    2. sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    3. sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    4. java.lang.reflect.Method.invoke(Unknown Source)
    4 frames
  3. Groovy
    ScriptBytecodeAdapter.invokeMethod0
    1. org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
    2. groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)
    3. groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:899)
    4. groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:740)
    5. org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:777)
    6. org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:757)
    7. org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:167)
    8. org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethod0(ScriptBytecodeAdapter.java:195)
    8 frames