Interface is not visible from ClassLoader when using a proxy?

前端 未结 3 654
面向向阳花
面向向阳花 2020-12-31 07:45

I am seeing following exception when I try to use dynamic proxy

 com.intellij.rt.execution.application.AppMain DynamicProxy.DynamicProxy
Exception in thread         


        
3条回答
  •  温柔的废话
    2020-12-31 07:52

    When your DynamicProxy tries to do Class.forName(youInterfaceClass.getName()) the resulting java.lang.Class instance is different from the one you passed when you created the proxy. In other words you have two class objects with the same name and the proxy is not sure which one is the right one (doesn't matter whether they are the same).

    Usually, this happens when the interface you are trying to proxy is in a library loaded through two different classloaders (i.e. Tomcat's 'common' and 'application').

    If this doesn't help, please post more info on your application - especially if you are using any application server, Spring or OSGi.

提交回复
热议问题