V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
PUGE
V2EX  ›  Java

dubbo 的 xml 配置问题

  •  
  •   PUGE · 2020-02-13 23:48:19 +08:00 · 2928 次点击
    这是一个创建于 1744 天前的主题,其中的信息可能已经有所发展或是发生改变。
    改造个老项目,配置 xml 老报这个错:

    org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [dubbo.xml]; nested exception is org.springframework.beans.FatalBeanException: Invalid NamespaceHandler class [org.apache.dubbo.config.spring.schema.DubboNamespaceHandler] for namespace [http://dubbo.apache.org/schema/dubbo]: problem with handler class file or dependent class; nested exception is java.lang.VerifyError: class org.apache.dubbo.config.spring.schema.DubboNamespaceHandler overrides final method parse.(Lorg/w3c/dom/Element;Lorg/springframework/beans/factory/xml/ParserContext;)Lorg/springframework/beans/factory/config/BeanDefinition;

    有不有老哥遇到这个问题啊?

    我的 dubbo.xml 配置:

    <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
    xmlns="http://www.springframework.org/schema/beans"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
    http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd">

    <dubbo:application name="test"/>
    <dubbo:registry group="${dubbo_reference_group}" address="${dubbo_registry_address}"/>
    <dubbo:reference id="servicexxx" check="false" interface="com.t.defaukt.Servicexxx" version="1.0.0"/>
    </beans>
    18 条回复    2020-02-14 19:46:36 +08:00
    PUGE
        2
    PUGE  
    OP
       2020-02-14 09:54:58 +08:00
    @lxk11153 还是这个提示,NamespaceHandler 这个好像是解析自定义标签,看样子是标签解析不成功

    Caused by: org.springframework.beans.FatalBeanException: Invalid NamespaceHandler class [org.apache.dubbo.config.spring.schema.DubboNamespaceHandler] for namespace [http://code.alibabatech.com/schema/dubbo]: problem with handler class file or dependent class; nested exception is java.lang.VerifyError: class org.apache.dubbo.config.spring.schema.DubboNamespaceHandler overrides final method parse.(Lorg/w3c/dom/Element;Lorg/springframework/beans/factory/xml/ParserContext;)Lorg/springframework/beans/factory/config/BeanDefinition;
    at org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver.resolve(DefaultNamespaceHandlerResolver.java:138)
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1292)
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1287)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:135)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:92)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:507)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:398)
    ... 32 more
    Caused by: java.lang.VerifyError: class org.apache.dubbo.config.spring.schema.DubboNamespaceHandler overrides final method parse.(Lorg/w3c/dom/Element;Lorg/springframework/beans/factory/xml/ParserContext;)Lorg/springframework/beans/factory/config/BeanDefinition;
    lxk11153
        3
    lxk11153  
       2020-02-14 11:31:02 +08:00
    由 dubbo-*.*.*.jar 下 /META-INF/spring.schemas 可知 (/META-INF/spring.handlers)
    http\://dubbo.apache.org/schema/dubbo/dubbo.xsd=META-INF/dubbo.xsd
    http\://code.alibabatech.com/schema/dubbo/dubbo.xsd=META-INF/compat/dubbo.xsd
    配置 dubbo.apache.orgcode.alibabatech.com (for compat)是一样的
    PUGE
        4
    PUGE  
    OP
       2020-02-14 11:42:09 +08:00
    @lxk11153 看了下,确实是一样的
    lxk11153
        5
    lxk11153  
       2020-02-14 11:45:03 +08:00
    是不是 java 版本问题? dubbo-*.*.*.jar 是几版本(/java 几编译的),由 java 几运行?
    PUGE
        6
    PUGE  
    OP
       2020-02-14 11:51:20 +08:00
    @lxk11153 我这边是消费者,用的 java8,spring 有点老,用的 2.5
    PUGE
        7
    PUGE  
    OP
       2020-02-14 11:58:05 +08:00
    @lxk11153 看了下报错在 package org.springframework.beans.factory.xml ,catch 了 LinkageError 可能是兼容的问题,我在研究下
    public NamespaceHandler resolve(String namespaceUri) {
    Map handlerMappings = this.getHandlerMappings();
    Object handlerOrClassName = handlerMappings.get(namespaceUri);
    if (handlerOrClassName == null) {
    return null;
    } else if (handlerOrClassName instanceof NamespaceHandler) {
    return (NamespaceHandler)handlerOrClassName;
    } else {
    String className = (String)handlerOrClassName;

    try {
    Class handlerClass = ClassUtils.forName(className, this.classLoader);
    if (!NamespaceHandler.class.isAssignableFrom(handlerClass)) {
    throw new FatalBeanException("Class [" + className + "] for namespace [" + namespaceUri + "] does not implement the [" + NamespaceHandler.class.getName() + "] interface");
    } else {
    NamespaceHandler namespaceHandler = (NamespaceHandler)BeanUtils.instantiateClass(handlerClass);
    namespaceHandler.init();
    handlerMappings.put(namespaceUri, namespaceHandler);
    return namespaceHandler;
    }
    } catch (ClassNotFoundException var7) {
    throw new FatalBeanException("NamespaceHandler class [" + className + "] for namespace [" + namespaceUri + "] not found", var7);
    } catch (LinkageError var8) {
    throw new FatalBeanException("Invalid NamespaceHandler class [" + className + "] for namespace [" + namespaceUri + "]: problem with handler class file or dependent class", var8);
    }
    }
    }
    lxk11153
        8
    lxk11153  
       2020-02-14 11:58:51 +08:00
    或者可以发联系 F 式远程解决,收费 50 [滑稽] See /t/611554
    lxk11153
        9
    lxk11153  
       2020-02-14 12:00:27 +08:00
    Java 8 and Spring 2.5 好像是不兼容的,网上一搜就有
    lxk11153
        10
    lxk11153  
       2020-02-14 12:02:23 +08:00   ❤️ 1
    比如覆盖 org.springframework.core.JdkVersion 可以解决
    https://gist.github.com/xluer/e48633afa658bd794d754d5508a864c4
    PUGE
        11
    PUGE  
    OP
       2020-02-14 12:08:20 +08:00
    @lxk11153 谢谢,应该不是这个问题,已经加上了。。。
    lxk11153
        12
    lxk11153  
       2020-02-14 12:10:55 +08:00
    @PUGE #11 "加上了"?加上什么?指那贴的 17 楼吗?那不是我的 F 式
    bbao
        13
    bbao  
       2020-02-14 12:26:07 +08:00
    现在用 dubbo 的多还是 dubbox 的多?
    lxk11153
        14
    lxk11153  
       2020-02-14 12:28:11 +08:00
    @bbao #13 当然是 dubbo 咯,dubbo 又更新了(apache),dubbox 都多少年没更新了
    bbao
        15
    bbao  
       2020-02-14 12:32:31 +08:00
    @lxk11153 dubbo 还结合 zk 使用呗? 没换其他的,比如 etcd
    PUGE
        16
    PUGE  
    OP
       2020-02-14 12:47:25 +08:00
    @lxk11153 覆盖 org.springframework.core.JdkVersion 这个已经加上 :)
    lxk11153
        17
    lxk11153  
       2020-02-14 12:52:50 +08:00
    KnightYoung
        18
    KnightYoung  
       2020-02-14 19:46:36 +08:00
    撞头像了老铁
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   996 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 22:43 · PVG 06:43 · LAX 14:43 · JFK 17:43
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.