Skip to content

Conflict with some mechanism in Dubbo 2.6.2 #1769

Closed

Description

@3zamn

Please answer these questions before submitting your issue.

  • Why do you submit this issue?
  • Question or discussion
  • Bug
  • Requirement
  • Feature or performance improvement

Question

  • What do you want to know?
    extension.SpringExtensionFactory - [DUBBO] No spring extension(bean) named:skyWalkingDynamicField, try to find an extension(bean) of type java.lang.Object, dubbo version: oss, current host: 192.168.0.3
    ERROR extension.ExtensionLoader - [DUBBO] fail to inject via method setSkyWalkingDynamicField of interface com.alibaba.dubbo.rpc.Filter:

Bug

  • Which version of SkyWalking, OS and JRE?
    SkyWalking5.6.0、dubbo2.6.2、jre1.8

  • Which company or project?

  • What happen?
    If possible, provide a way for reproducing the error. e.g. demo application, component version.
    dubbo2.6.0- is ok、but dubbo2.6.2+ didn't support


Requirement or improvement

Please support dubbo2.6.2+

Activity

  1. added
    bug
    agent
    plugin
    on Oct 16, 2018
  2. wu-sheng commented on Oct 16, 2018

    @wu-sheng
    Member

    @ascrutae please take a look at this.

  3. changed the title [-]It does not dubbo v2.6.2+?[/-] [+]It does not support dubbo v2.6.2+?[/+] on Oct 17, 2018
  4. KerwinAusten commented on Oct 23, 2018

    @KerwinAusten

    @wu-sheng Hey, I also met this problem and I found the reason. Because Skywalking will add setSkyWalkingDynamicField(Object) to class MonitorFilter and this conflicts with dubbo's spi extention mechanism.

    /*
     * com.alibaba.dubbo.common.extension.ExtensionLoader
     * Here dubbo's spi extention mechanism will traverse all the public set method
     */
    private T injectExtension(T instance) {
        try {
            if (objectFactory != null) {
                for (Method method : instance.getClass().getMethods()) {
                    if (method.getName().startsWith("set")
                            && method.getParameterTypes().length == 1
                            && Modifier.isPublic(method.getModifiers())) {
                        Class<?> pt = method.getParameterTypes()[0];
                        try {
                            String property = method.getName().length() > 3 ? method.getName().substring(3, 4).toLowerCase() + method.getName().substring(4) : "";
                            Object object = objectFactory.getExtension(pt, property);
                            if (object != null) {
                                method.invoke(instance, object);
                            }
                        } catch (Exception e) {
                            logger.error("fail to inject via method " + method.getName()
                                    + " of interface " + type.getName() + ": " + e.getMessage(), e);
                        }
                    }
                }
            }
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
        }
        return instance;
    }

    Before dubbo 2.6.3, the extentionFactory just get bean by name, so there is no errro.

    /*
     * com.alibaba.dubbo.config.spring.extension.SpringExtensionFactory
     */
    @Override
    @SuppressWarnings("unchecked")
    public <T> T getExtension(Class<T> type, String name) {
        for (ApplicationContext context : contexts) {
            if (context.containsBean(name)) {
                Object bean = context.getBean(name);
                if (type.isInstance(bean)) {
                    return (T) bean;
                }
            }
        }
        return null;
    }

    After, dubbo monify the code, it also get bean by type and this throw the exception.

    @Override
    @SuppressWarnings("unchecked")
    public <T> T getExtension(Class<T> type, String name) {
        for (ApplicationContext context : contexts) {
            if (context.containsBean(name)) {
                Object bean = context.getBean(name);
                if (type.isInstance(bean)) {
                    return (T) bean;
                }
            }
        }
    
        logger.warn("No spring extension(bean) named:" + name + ", try to find an extension(bean) of type " + type.getName());
    
        for (ApplicationContext context : contexts) {
            try {
                return context.getBean(type);
            } catch (NoUniqueBeanDefinitionException multiBeanExe) {
                //here will throw exception because setSkyWalkingDynamicField() type is Object and spring will find many beans
                throw multiBeanExe;
            } catch (NoSuchBeanDefinitionException noBeanExe) {
                if (logger.isDebugEnabled()) {
                    logger.debug("Error when get spring extension(bean) for type:" + type.getName(), noBeanExe);
                }
            }
        }
    
        logger.warn("No spring extension(bean) named:" + name + ", type:" + type.getName() + " found, stop get bean.");
    
        return null;
    }

    Emmm....Maybe you can communicate with dubbo....

  5. wu-sheng commented on Oct 23, 2018

    @wu-sheng
    Member

    @IcebergXTY Thanks for the feedback. I already dropped an request in Dubbo mail list, https://lists.apache.org/thread.html/ed79a0284fddfedc53c96e5666a059617693cd4d7628c32de2935ea4@%3Cdev.dubbo.apache.org%3E . Let's wait and see what are they going to response, and we could work from here.

  6. diecui1202 commented on Oct 23, 2018

    @diecui1202

    @chickenlj I've checked the git commit log, this change is from you. Could u pls. take some time to look at it?

  7. chickenlj commented on Oct 23, 2018

    @chickenlj

    Sure, I am here on it.

    I guess the newly added method setSkyWalkingDynamicField(Object) from SkyWalking is not expected to be automatically injected by Dubbo framework. To make Dubbo more adaptable, I think we should do the following:

    1. A method level annotation to enable auto-injection or not.
    2. Special handling for generic Object parameter type.
  8. chickenlj commented on Oct 23, 2018

    @chickenlj

    @IcebergXTY @wu-sheng Do you think this will solve your problem?

  9. wu-sheng commented on Oct 23, 2018

    @wu-sheng
    Member

    A method level annotation to enable auto-injection or not.

    @chickenlj I hope the default is not :) SkyWalking will add this method to all enhanced classes, we can't add an annotation belongs to Dubbo only, may trigger ClassNotFound in other scenarios.

    Or, when could not find the inject way, just ignore. The auto set should not be active always from my perspective.

  10. chickenlj commented on Oct 23, 2018

    @chickenlj

    A method level annotation to enable auto-injection or not.

    @chickenlj I hope the default is not :) SkyWalking will add this method to all enhanced classes, we can't add an annotation belongs to Dubbo only, may trigger ClassNotFound in other scenarios.

    Set the default value to not would bring lots of changes to Dubbo, many methods would need to add an annotation and enable injection. Can't SkyWalking just add an annotation when instrumenting Dubbo?
    Anyway, I think Dubbo need an annotation to flexibly control the injection action.

    Or, when could not find the inject way, just ignore. The auto set should not be active always from my perspective.

    Sounds reasonable, I will consider the possibility of ignoring it when fails.

  11. 15 remaining items

  12. added this to the 6.0.0-beta milestone on Nov 23, 2018
  13. wu-sheng commented on Nov 23, 2018

    @wu-sheng
    Member

    Great. Closing this. Supported is back in 2.6.5 release.

  14. qixiaobo commented on Jul 29, 2019

    @qixiaobo

    @chickenlj @wu-sheng Sad……Because dubbo 2.6.6 has bugs so I degrade to dubbo 2.6.4……But I meet this problem. I meet the problem as same as 2009 which QQ or 360 I must choose at most one……

    apache/dubbo#4612

  15. wu-sheng commented on Jul 29, 2019

    @wu-sheng
    Member

    They are talking about 2.6.7 is available, is that a better choice? This is also a Dubbo bug... sadly.

  16. qixiaobo commented on Jul 29, 2019

    @qixiaobo

    They are talking about 2.6.7 is available, is that a better choice? This is also a Dubbo bug... sadly.

    Sad……
    2.6.X merges my pr…… But 2.6.7 never ……
    image
    image
    Maybe 2.6.8…… I cannot wait for it

  17. wu-sheng commented on Jul 29, 2019

    @wu-sheng
    Member

    Apache can't randomly release, and each release is unchangeable. So... I am afraid Dubbo community did the right thing. Only the next release is an option. We could ask a Dubbo committer do patch release, such as 2.6.7-patch1, if the community accepts that.

  18. qixiaobo commented on Jul 29, 2019

    @qixiaobo

    You are right, so spring-cloud-alibaba comes back to alibaba repo. Thanks for replying

  19. qixiaobo commented on Jul 30, 2019

    @qixiaobo

    How about I add a spring bean named skyWalkingDynamicField to avoid this problem ? @wu-sheng In this mechanism maybe skywalking never need this field?

  20. wu-sheng commented on Jul 30, 2019

    @wu-sheng
    Member

    SkyWalking plugin requires this field. I doubt this w/ highly possible risks.

  21. qixiaobo commented on Jul 30, 2019

    @qixiaobo

    SkyWalking plugin requires this field. I doubt this w/ highly possible risks.

    I have no other choices since dubbo 2.6.5+ has a bug cannot serialize and 2.6.8 is not release yet…… Maybe I can try?

  22. wu-sheng commented on Jul 30, 2019

    @wu-sheng
    Member

    You could try :) I am just concerned that, it will break the SpringMVC plugin.

  23. qixiaobo commented on Jul 30, 2019

    @qixiaobo

    You could try :) I am just concerned that, it will break the SpringMVC plugin.

    Or maybe I can delete the dubbo plugin?[It may works]
    Also I consider about delete the dubbo Monitorfilter [Skywalking just enchace this class]--->The same result with delete dubbo plugin

  24. qixiaobo commented on Jul 30, 2019

    @qixiaobo
    /**
     * https://github.com/apache/skywalking/issues/1769
     */
    @Bean
    public String skyWalkingDynamicField() {
        return "avoid skywalking conflicts with dubbo 2.6.5-";
    }

    I add this code to my spring config , and it works~

  25. wu-sheng commented on Jul 30, 2019

    @wu-sheng
    Member

    That is luck :) Hope it would break other things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agentbugplugin

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions