Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dubbo start failed with nacos-spring-context 1.0.0 #7115

Closed
2 tasks
robinZhao opened this issue Jan 20, 2021 · 6 comments
Closed
2 tasks

dubbo start failed with nacos-spring-context 1.0.0 #7115

robinZhao opened this issue Jan 20, 2021 · 6 comments

Comments

@robinZhao
Copy link

  • I have searched the issues of this repository and believe that this is not a duplicate.
  • I have checked the FAQ of this repository and believe that this is not a duplicate.

Environment

  • Dubbo version: 2.7.7/2.7.8
  • Operating System version: xxx
  • Java version: xxx

Steps to reproduce this issue

  1. start

Pls. provide [GitHub address] to reproduce this issue.

Expected Result

What do you expected from the above steps?

Actual Result

What actually happens?

If there is an exception, please attach the exception trace:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'xxxxxController': Injection of @DubboReference dependencies is failed; nested exception is java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Class
	at com.alibaba.spring.beans.factory.annotation.AbstractAnnotationBeanPostProcessor.postProcessPropertyValues(AbstractAnnotationBeanPostProcessor.java:183) ~[spring-context-support-1.0.11.jar:?]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1425) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:226) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:897) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:879) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) ~[spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) [spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) [spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.3.2.RELEASE.jar:2.3.2.RELEASE]
	at com.echovin.demo.visit.VisitWebApplication.main(VisitWebApplication.java:12) [main/:?]
Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Class
	at org.apache.dubbo.config.spring.util.DubboAnnotationUtils.resolveServiceInterfaceClass(DubboAnnotationUtils.java:95) ~[dubbo-2.7.8.jar:2.7.8]
	at org.apache.dubbo.config.spring.util.DubboAnnotationUtils.resolveInterfaceName(DubboAnnotationUtils.java:78) ~[dubbo-2.7.8.jar:2.7.8]
	at org.apache.dubbo.config.spring.beans.factory.annotation.ServiceBeanNameBuilder.<init>(ServiceBeanNameBuilder.java:65) ~[dubbo-2.7.8.jar:2.7.8]
	at org.apache.dubbo.config.spring.beans.factory.annotation.ServiceBeanNameBuilder.create(ServiceBeanNameBuilder.java:78) ~[dubbo-2.7.8.jar:2.7.8]
	at org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor.buildReferencedBeanName(ReferenceAnnotationBeanPostProcessor.java:303) ~[dubbo-2.7.8.jar:2.7.8]
	at org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor.buildInjectedObjectCacheKey(ReferenceAnnotationBeanPostProcessor.java:292) ~[dubbo-2.7.8.jar:2.7.8]
	at com.alibaba.spring.beans.factory.annotation.AbstractAnnotationBeanPostProcessor.getInjectedObject(AbstractAnnotationBeanPostProcessor.java:404) ~[spring-context-support-1.0.11.jar:?]
	at com.alibaba.spring.beans.factory.annotation.AbstractAnnotationBeanPostProcessor$AnnotatedFieldElement.inject(AbstractAnnotationBeanPostProcessor.java:626) ~[spring-context-support-1.0.11.jar:?]
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:130) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
	at com.alibaba.spring.beans.factory.annotation.AbstractAnnotationBeanPostProcessor.postProcessPropertyValues(AbstractAnnotationBeanPostProcessor.java:179) ~[spring-context-support-1.0.11.jar:?]
	... 18 more
@robinZhao
Copy link
Author

robinZhao commented Jan 20, 2021

update nacos-spring-context to 1.0.0 because nacos-spring-context0.3.6 can't read yaml in nacos when using nacos-client1.3.2,
nacos-spring-context 1.0.0 dependency spring-context-support 1.0.11
in spring-context-support 1.0.11
AbstractAnnotationBeanPostProcessor read annotation property interfaceClass=void as interfaceClass="void"

code in AbstractAnnotationBeanPostProcessor

    /**
     * whether to turn Class references into Strings (for
     * compatibility with {@link org.springframework.core.type.AnnotationMetadata} or to
     * preserve them as Class references
     *
     * @since 1.0.11
     */
    private boolean classValuesAsString = true;
......
    protected AnnotationAttributes doGetAnnotationAttributes(AnnotatedElement annotatedElement,
                                                             Class<? extends Annotation> annotationType) {
        return getAnnotationAttributes(annotatedElement, annotationType, getEnvironment(),
                classValuesAsString, nestedAnnotationsAsMap, ignoreDefaultValue, tryMergedAnnotation);
    }

@vantis-zh
Copy link

I've got the same error.

@wsrhp
Copy link

wsrhp commented Mar 1, 2021

same problem

@zhaog
Copy link

zhaog commented Mar 21, 2021

downgrade spring-context-support from 1.0.11 to 1.0.10 worked.

@zrlw
Copy link
Contributor

zrlw commented Jul 13, 2021

it might be fixed by #8217

@CrazyHZM
Copy link
Member

CrazyHZM commented Oct 9, 2021

Try it with the latest version, if you still have problems, you can reopen the issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants