Announcement Announcement Module
No announcement yet.
ReflectionUtils.invokeMethod Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • ReflectionUtils.invokeMethod


    In org.springframework.osgi.util.internal.ReflectionU tils #invokeMethod(java.lang.reflect.Method, Object, Object[])

    Java is throwing an exception in: return method.invoke(target, args);

    This only happens when spring passes a Proxy class as the target. At the moment as a workaround I just make sure that spring do not proxy these classes. In my case it happens when using:

    <osgi:list id="plugins" cardinality="0..N" interface="com.blah.blah.Plugin">
    <osgi:listener bind-method="registerPlugin" unbind-method="unregisterPlugin" ref="pluginManager" />

    pluginManger is proxied and is the target in the method above.

    The exception below:

    threw exception when passing service type [$Proxy143]
    java.lang.IllegalArgumentException: object is not an instance of declaring class
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)[:1.7.0_07]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native[:1.7.0_07]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De[:1.7.0_07]
    at java.lang.reflect.Method.invoke([:1.7.0_07]
    at org.springframework.osgi.util.internal.ReflectionU tils.invokeMethod([90:org.springframework.osgi.core:1.2.1]

    Any idea if this is a bug?

  • #2
    No it isn't as it is a proxy (and depending on the type of proxy it is indeed not a type of declaring class).

    Also why is this in container... This clearly is an Spring DM class and not a Spring class and Spring DM isn't continued anymore and has been donated to the Eclipse foundation.


    • #3
      Thanks, I'll take this to another forum.