dubbo 的 xml 配置问题

2020-02-13 23:48:19 +08:00
 PUGE
改造个老项目,配置 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>
2932 次点击
所在节点    Java
18 条回复
lxk11153
2020-02-14 01:03:05 +08:00
PUGE
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
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
2020-02-14 11:42:09 +08:00
@lxk11153 看了下,确实是一样的
lxk11153
2020-02-14 11:45:03 +08:00
是不是 java 版本问题? dubbo-*.*.*.jar 是几版本(/java 几编译的),由 java 几运行?
PUGE
2020-02-14 11:51:20 +08:00
@lxk11153 我这边是消费者,用的 java8,spring 有点老,用的 2.5
PUGE
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
2020-02-14 11:58:51 +08:00
或者可以发联系 F 式远程解决,收费 50 [滑稽] See /t/611554
lxk11153
2020-02-14 12:00:27 +08:00
Java 8 and Spring 2.5 好像是不兼容的,网上一搜就有
lxk11153
2020-02-14 12:02:23 +08:00
比如覆盖 org.springframework.core.JdkVersion 可以解决
https://gist.github.com/xluer/e48633afa658bd794d754d5508a864c4
PUGE
2020-02-14 12:08:20 +08:00
@lxk11153 谢谢,应该不是这个问题,已经加上了。。。
lxk11153
2020-02-14 12:10:55 +08:00
@PUGE #11 "加上了"?加上什么?指那贴的 17 楼吗?那不是我的 F 式
bbao
2020-02-14 12:26:07 +08:00
现在用 dubbo 的多还是 dubbox 的多?
lxk11153
2020-02-14 12:28:11 +08:00
@bbao #13 当然是 dubbo 咯,dubbo 又更新了(apache),dubbox 都多少年没更新了
bbao
2020-02-14 12:32:31 +08:00
@lxk11153 dubbo 还结合 zk 使用呗? 没换其他的,比如 etcd
PUGE
2020-02-14 12:47:25 +08:00
@lxk11153 覆盖 org.springframework.core.JdkVersion 这个已经加上 :)
lxk11153
2020-02-14 12:52:50 +08:00
KnightYoung
2020-02-14 19:46:36 +08:00
撞头像了老铁

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/644415

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX