dubbo 常见错误

1. Caused by: java.lang.reflect.MalformedParameterizedTypeException

启动时报错,原因是dubbo 依赖 spring 2.5.6.SEC03,而我项目中有用spring 3.2.4.RELEASE,所以导致冲突。 在maven中把dubbo中的spring依赖去除就可以了。

如果你们项目中也报这个错,很可能也是因为jar包冲突造成的

		<dependency>
			<groupId>com.alibaba</groupId>
			<artifactId>dubbo</artifactId>
			<exclusions>  
	            <exclusion>  
	                <artifactId>spring</artifactId>  
	                <groupId>org.springframework</groupId>  
	            </exclusion>  
            </exclusions>  
		</dependency>

2. Caused by: java.lang.IllegalStateException: Context namespace element 'annotation-config' and its parser class [org.springframework.context.annotation.AnnotationConfigBeanDefinitionParser] are only available on JDK 1.5 and higher

at org.springframework.context.config.ContextNamespaceHandler$1.parse(ContextNamespaceHandler.java:65)
at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:69)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1297)
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)
... 22 more

错误原因:http://stackoverflow.com/questions/23813369/spring-java-error-namespace-element-annotation-config-on-jdk-1-5-and-high

因为使用了 jdk1.8, 而dubbo 依赖 Spring 2.5 ,而Spring2.5仅仅支持 jdk1.5 到 jdk 1.7, 所以jdk 1.8 不被识别,所以报错。

3. Caused by: org.xml.sax.SAXParseException; lineNumber: 9; columnNumber: 46; cvc-complex-type.2.4.c: 通配符的匹配很全面, 但无法找到元素 'dubbo:application' 的声明。

该错误是因为没有引入 dubbo jar包。加上依赖就行了:

		<dependency>
			<groupId>com.alibaba</groupId>
			<artifactId>dubbo</artifactId>
                        <version>2.8.4</version>
	        </dependency>

4. Unsupported major.minor version 52.0 (unable to load class

出现该错误是由于class编译器的JDK版本高于运行期的JDK版本。

比如我在运行Tomcat servlet时出现该错误,是由于tomcat运行时是1.7的JDK,Eclipse编译时则是1.8

修改方法:保证编译器和运行期的JDK版本一致。

5. cvc-complex-type.2.4.c

find dubbo.xsd in dubbo-master, copy to anthor directory.

Eclipse –> window –> Preferences –> XML –> XML Catalog

select User Specified Entries –> add

Location the dubbo.xsd path

Key type Schema location

Key http://code.alibabatech.com/schema/dubbo

then add other config

key http://code.alibabatech.com/schema/dubbo/dubbo.xsd

原文地址:https://www.cnblogs.com/alex-blog/p/5729125.html