You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2022/12/26 07:00:43 UTC

[GitHub] [dubbo] ddfeiyu opened a new issue, #11204: 自定义AbstractRouter报错ClassNotFoundException: org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate

ddfeiyu opened a new issue, #11204:
URL: https://github.com/apache/dubbo/issues/11204

   <!-- If you need to report a security issue please visit https://github.com/apache/dubbo/security/policy -->
   
   - [ ] I have searched the [issues](https://github.com/apache/dubbo/issues) of this repository and believe that this is not a duplicate.
   
   ### Environment
   
   * Dubbo version:    3.2.0-beta.2
   * Operating System version:    Apple M1 Pro
   * Java version:  1.8
   
   ### Steps to reproduce this issue
   
   1.   class TrafficTagRouter extends AbstractRouter 
   2.  启动报错
   3. xxx
   
   Pls. provide [GitHub address] to reproduce this issue.
   
   ### Expected Behavior
   
   <!-- What do you expect from the above steps?-->
   
   ### Actual Behavior
   
   <!-- What actually happens? -->
   
   If there is an exception, please attach the exception trace:
   
   ```java
   
   
   import org.apache.dubbo.rpc.cluster.router.AbstractRouter;
   import org.slf4j.Logger;
   import org.slf4j.LoggerFactory;
   
   import java.lang.reflect.InvocationTargetException;
   import java.lang.reflect.Method;
   import java.util.Arrays;
   import java.util.Comparator;
   import java.util.HashMap;
   import java.util.List;
   import java.util.Map;
   import java.util.Optional;
   import java.util.Set;
   import java.util.stream.Collectors;
   
   /**
    * @desc: 流量标签路由,根据流量标签和配置过滤出可用的服务版本
    **/
   public class TrafficTagRouter extends AbstractRouter {
   
       private static final Logger logger = LoggerFactory.getLogger(TrafficTagRouter.class);
   
       private Method getProviderUrl;
   
       public TrafficTagRouter(URL url) {
           super(url);
           try {
               Class<?> invokerClass = Class.forName("org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate");
               getProviderUrl = invokerClass.getDeclaredMethod("getProviderUrl");
               getProviderUrl.setAccessible(true);
           } catch (ClassNotFoundException | NoSuchMethodException e) {
               logger.debug("router reflection exception", e);
           }
       }
   
   }
    ```
   
   报错
   ```java
   2022-12-26 14:54:22,022 DEBUG [com.test.common.router.router.TrafficTagRouter]  - router reflection exception
   java.lang.ClassNotFoundException: org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate
   	at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1420)
   	at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1228)
   	at java.lang.Class.forName0(Native Method)
   	at java.lang.Class.forName(Class.java:264)
   	at com.iplatform.common.router.router.TrafficTagRouter.<init>(TrafficTagRouter.java:41)
   	at com.iplatform.common.router.router.TrafficTagRouterFactory.createRouter(TrafficTagRouterFactory.java:18)
   	at org.apache.dubbo.rpc.cluster.CacheableRouterFactory.lambda$getRouter$0(CacheableRouterFactory.java:33)
   	at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)
   	at org.apache.dubbo.rpc.cluster.CacheableRouterFactory.getRouter(CacheableRouterFactory.java:33)
   	at org.apache.dubbo.rpc.cluster.RouterChain.lambda$buildSingleChain$0(RouterChain.java:64)
   	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
   	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1384)
   	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
   	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
   	at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
   	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
   	at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
   	at org.apache.dubbo.rpc.cluster.RouterChain.buildSingleChain(RouterChain.java:66)
   	at org.apache.dubbo.rpc.cluster.RouterChain.buildChain(RouterChain.java:52)
   	at org.apache.dubbo.registry.integration.DynamicDirectory.buildRouterChain(DynamicDirectory.java:280)
   	at org.apache.dubbo.registry.integration.RegistryProtocol.doCreateInvoker(RegistryProtocol.java:569)
   	at org.apache.dubbo.registry.integration.InterfaceCompatibleRegistryProtocol.getInvoker(InterfaceCompatibleRegistryProtocol.java:58)
   	at org.apache.dubbo.registry.client.migration.MigrationInvoker.refreshInterfaceInvoker(MigrationInvoker.java:461)
   	at org.apache.dubbo.registry.client.migration.MigrationInvoker.migrateToApplicationFirstInvoker(MigrationInvoker.java:244)
   	at org.apache.dubbo.registry.client.migration.MigrationRuleHandler.refreshInvoker(MigrationRuleHandler.java:76)
   	at org.apache.dubbo.registry.client.migration.MigrationRuleHandler.doMigrate(MigrationRuleHandler.java:60)
   	at org.apache.dubbo.registry.client.migration.MigrationRuleListener.onRefer(MigrationRuleListener.java:247)
   	at org.apache.dubbo.registry.integration.RegistryProtocol.interceptInvoker(RegistryProtocol.java:535)
   	at org.apache.dubbo.registry.integration.RegistryProtocol.doRefer(RegistryProtocol.java:505)
   	at org.apache.dubbo.registry.integration.RegistryProtocol.refer(RegistryProtocol.java:487)
   	at org.apache.dubbo.rpc.protocol.ProtocolListenerWrapper.refer(ProtocolListenerWrapper.java:74)
   	at org.apache.dubbo.qos.protocol.QosProtocolWrapper.refer(QosProtocolWrapper.java:81)
   	at org.apache.dubbo.rpc.cluster.filter.ProtocolFilterWrapper.refer(ProtocolFilterWrapper.java:71)
   	at org.apache.dubbo.rpc.protocol.ProtocolSerializationWrapper.refer(ProtocolSerializationWrapper.java:52)
   	at org.apache.dubbo.rpc.Protocol$Adaptive.refer(Protocol$Adaptive.java)
   	at org.apache.dubbo.config.ReferenceConfig.createInvokerForRemote(ReferenceConfig.java:605)
   	at org.apache.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:439)
   	at org.apache.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:297)
   	at org.apache.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:231)
   	at org.apache.dubbo.config.utils.SimpleReferenceCache.get(SimpleReferenceCache.java:131)
   	at org.apache.dubbo.config.deploy.DefaultModuleDeployer.lambda$referServices$6(DefaultModuleDeployer.java:396)
   	at java.util.concurrent.ConcurrentHashMap$ValuesView.forEach(ConcurrentHashMap.java:4707)
   	at org.apache.dubbo.config.deploy.DefaultModuleDeployer.referServices(DefaultModuleDeployer.java:376)
   	at org.apache.dubbo.config.deploy.DefaultModuleDeployer.startSync(DefaultModuleDeployer.java:167)
   	at org.apache.dubbo.config.deploy.DefaultModuleDeployer.start(DefaultModuleDeployer.java:139)
   	at org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onContextRefreshedEvent(DubboDeployApplicationListener.java:113)
   	at org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onApplicationEvent(DubboDeployApplicationListener.java:102)
   	at org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onApplicationEvent(DubboDeployApplicationListener.java:47)
   	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
   	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
   	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
   	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:404)
   	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:361)
   	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:898)
   	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:554)
   	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:401)
   	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:292)
   	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:103)
   	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4764)
   	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5233)
   	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
   	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:753)
   	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:727)
   	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:695)
   	at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1775)
   	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.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:291)
   	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
   	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
   	at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:483)
   	at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:431)
   	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.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:291)
   	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
   	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
   	at com.sun.jmx.remote.security.MBeanServerAccessController.invoke(MBeanServerAccessController.java:468)
   	at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468)
   	at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76)
   	at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309)
   	at java.security.AccessController.doPrivileged(Native Method)
   	at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1408)
   	at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829)
   	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 sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357)
   	at sun.rmi.transport.Transport$1.run(Transport.java:200)
   	at sun.rmi.transport.Transport$1.run(Transport.java:197)
   	at java.security.AccessController.doPrivileged(Native Method)
   	at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
   	at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:573)
   	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:834)
   	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:688)
   	at java.security.AccessController.doPrivileged(Native Method)
   	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:687)
   	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
   	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
   	at java.lang.Thread.run(Thread.java:750)
   
   
   ````
   
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] AlbumenJ commented on issue #11204: 自定义AbstractRouter报错ClassNotFoundException: org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate

Posted by GitBox <gi...@apache.org>.
AlbumenJ commented on issue #11204:
URL: https://github.com/apache/dubbo/issues/11204#issuecomment-1365587720

   `org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate` 这个类在最新的 Dubbo 3 中确实已经不存在了,在 Router 中如果要获取所有地址的信息可以通过 route 的入参获取当前可用的 provider 信息,也可以通过实现 notify 接口获取每次注册中心推送的信息


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [I] 自定义AbstractRouter报错ClassNotFoundException: org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate [dubbo]

Posted by "CrazyHZM (via GitHub)" <gi...@apache.org>.
CrazyHZM closed issue #11204: 自定义AbstractRouter报错ClassNotFoundException: org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate
URL: https://github.com/apache/dubbo/issues/11204


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org