- [ ] I have searched the [issues](https://github.com/apache/dubbo/issues) of 
this repository and believe that this is not a duplicate.
- [ ] I have checked the 
[FAQ](https://github.com/apache/dubbo/blob/master/FAQ.md) of this repository 
and believe that this is not a duplicate.

### Environment

* Dubbo version: 所有版本
* Operating System version: 所有版本
* Java version: 所有版本

### Steps to reproduce this issue
1.使用自定义的classloader去加载一个jar。
2.初始化该jar里面的某个类,通过ReferenceConfig生成该类的rpc服务。
3.出现各种ClassNotFound或者生成代理类失败

Pls. provide [GitHub address] to reproduce this issue.
https://github.com/apache/dubbo/blob/master/dubbo-common/src/main/java/org/apache/dubbo/common/bytecode/Proxy.javahttps://github.com/apache/dubbo/blob/master/dubbo-common/src/main/java/org/apache/dubbo/common/bytecode/ClassGenerator.java

### Expected Result
期望dubbo生成代理类的时候使用Thread.currentThread.getContextClassLoader获得的ClassLoader或者要生成Interface的ClassLoader而不是写死直接使用系统的ClassLoader

What do you expected from the above steps?
修改上面两个类的默认ClassLoader获取方式

### Actual Result
 return getProxy(ClassHelper.getCallerClassLoader(ics[0]), ics);

What actually happens?
生成代理类异常

If there is an exception, please attach the exception trace:
Caused by: org.springframework.beans.factory.BeanCreationException: Error 
creating bean with name 'recommendDynamicService' defined in file 
[D:\project\project\vivoshop-recommend\recommend-core\target\classes\com\vivo\internet\recommend\core\service\impl\RecommendDynamicServiceImpl.class]:
 Invocation of init method failed; nested exception is 
java.lang.RuntimeException: java.lang.IllegalArgumentException: interface 
com.bbkmobile.iqoo.vivoshop.facade.recommend.ManualRecommendFacade is not 
visible from class loader
        at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1631)
 ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
        at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
 ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
        at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:481)
 ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
        at 
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312)
 ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
        at 
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
 ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
        at 
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)
 ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
        at 
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
 ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
        at 
org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:522)
 ~[spring-context-4.3.22.RELEASE.jar:4.3.22.RELEASE]
        at 
org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:496)
 ~[spring-context-4.3.22.RELEASE.jar:4.3.22.RELEASE]
        at 
org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:627)
 ~[spring-context-4.3.22.RELEASE.jar:4.3.22.RELEASE]
        at 
org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:171)
 ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
        at 
org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
 ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
        at 
org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:318)
 ~[spring-context-4.3.22.RELEASE.jar:4.3.22.RELEASE]
        ... 29 common frames omitted
Caused by: java.lang.RuntimeException: java.lang.IllegalArgumentException: 
interface com.bbkmobile.iqoo.vivoshop.facade.recommend.ManualRecommendFacade is 
not visible from class loader
        at 
com.vivo.internet.recommend.core.service.impl.RecommendDynamicServiceImpl.initAndReplaceDynamicProcessors(RecommendDynamicServiceImpl.java:208)
 ~[classes/:na]
        at 
com.vivo.internet.recommend.core.service.impl.RecommendDynamicServiceImpl.refreshAllDynamicServices(RecommendDynamicServiceImpl.java:167)
 ~[classes/:na]
        at 
com.vivo.internet.recommend.core.service.impl.RecommendDynamicServiceImpl.afterPropertiesSet(RecommendDynamicServiceImpl.java:246)
 ~[classes/:na]
        at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1689)
 ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
        at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1627)
 ~[spring-beans-4.3.22.RELEASE.jar:4.3.22.RELEASE]
        ... 41 common frames omitted
Caused by: java.lang.IllegalArgumentException: interface 
com.bbkmobile.iqoo.vivoshop.facade.recommend.ManualRecommendFacade is not 
visible from class loader
        at com.alibaba.dubbo.common.bytecode.Proxy.getProxy(Proxy.java:98) 
~[dubbo-3.0.7-VIVO.jar:3.0.7-VIVO]
        at com.alibaba.dubbo.common.bytecode.Proxy.getProxy(Proxy.java:67) 
~[dubbo-3.0.7-VIVO.jar:3.0.7-VIVO]
        at 
com.alibaba.dubbo.rpc.proxy.javassist.JavassistProxyFactory.getProxy(JavassistProxyFactory.java:35)
 ~[dubbo-3.0.7-VIVO.jar:3.0.7-VIVO]
        at 
com.alibaba.dubbo.rpc.proxy.AbstractProxyFactory.getProxy(AbstractProxyFactory.java:49)
 ~[dubbo-3.0.7-VIVO.jar:3.0.7-VIVO]
        at 
com.alibaba.dubbo.rpc.proxy.wrapper.StubProxyFactoryWrapper.getProxy(StubProxyFactoryWrapper.java:60)
 ~[dubbo-3.0.7-VIVO.jar:3.0.7-VIVO]
        at 
com.alibaba.dubbo.rpc.ProxyFactory$Adpative.getProxy(ProxyFactory$Adpative.java)
 ~[dubbo-3.0.7-VIVO.jar:3.0.7-VIVO]
        at 
com.alibaba.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:438) 
~[dubbo-3.0.7-VIVO.jar:3.0.7-VIVO]
        at 
com.alibaba.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:312) 
~[dubbo-3.0.7-VIVO.jar:3.0.7-VIVO]
        at 
com.alibaba.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:141) 
~[dubbo-3.0.7-VIVO.jar:3.0.7-VIVO]
        at 
com.vivo.internet.recommend.common.utils.DuuboUtils.getReferenceService(DuuboUtils.java:31)
 ~[classes/:na]
        at 
com.vivo.internet.recommend.core.service.impl.RecommendDynamicServiceImpl.initAndReplaceDynamicProcessors(RecommendDynamicServiceImpl.java:201)
 ~[classes/:na]
        ... 45 common frames omitte
```
Just put your stack trace here!
无


[ Full content available at: https://github.com/apache/dubbo/issues/5507 ]
This message was relayed via gitbox.apache.org for 
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to