apache / dubbo-spring-boot-project

Spring Boot Project for Apache Dubbo
https://dubbo.apache.org
Apache License 2.0
5.41k stars 1.88k forks source link

Is it incompatible with Spring Boot 2.0? #93

Closed galaxy2000 closed 6 years ago

galaxy2000 commented 6 years ago

I got the follow exception stack with SpringBoot 2.0,

   2018-04-01 10:26:57.259 ERROR 83292 --- [ main] o.s.boot.SpringApplication : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serviceAnnotationBeanPostProcessor' defined in class path resource [com/alibaba/boot/dubbo/autoconfigure/DubboAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.alibaba.dubbo.config.spring.beans.factory.annotation.ServiceAnnotationBeanPostProcessor]: Factory method 'serviceAnnotationBeanPostProcessor' threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/boot/bind/RelaxedPropertyResolver
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:587) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1250) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1099) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:312) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:205) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:116) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:693) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752) [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:388) [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246) [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1234) [spring-boot-2.0.0.RELEASE.jar:2.0.0.RELEASE]
    at com.example.demo.DemoApplication.main(DemoApplication.java:12) [classes/:na]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.alibaba.dubbo.config.spring.beans.factory.annotation.ServiceAnnotationBeanPostProcessor]: Factory method 'serviceAnnotationBeanPostProcessor' threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/boot/bind/RelaxedPropertyResolver
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:579) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    ... 17 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/bind/RelaxedPropertyResolver
    at com.alibaba.boot.dubbo.autoconfigure.DubboAutoConfiguration.serviceAnnotationBeanPostProcessor(DubboAutoConfiguration.java:95) ~[dubbo-spring-boot-autoconfigure-0.1.0.jar:0.1.0]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_66]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_66]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_66]
    at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_66]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE]
    ... 18 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.bind.RelaxedPropertyResolver
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_66]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_66]
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0_66]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_66]
    ... 24 common frames omitted

the pom.xml


  <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <!--<version>1.5.10.RELEASE</version>-->
        <version>2.0.0.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.alibaba.boot</groupId>
            <artifactId>dubbo-spring-boot-starter</artifactId>
            <version>0.1.0</version>
        </dependency>
    </dependencies>
c297186864 commented 6 years ago

+1

neesonqk commented 6 years ago

+1

suclogger commented 6 years ago

@galaxy2000 @c297186864 @neesonqk

For now, dubbo-spring-boot-starter will separate two versions for Spring Boot 2.x and 1.x once release :

Please wait for final release or pull code from branch 0.2.0 and compile yourself.

c297186864 commented 6 years ago

It was two weeks ago that it was going to go online. But the delay has not been known for any reason.

mercyblitz commented 6 years ago

@c297186864 sorry for waiting, for now, Dubbo is an incubator apache project , thus release will become slow.

neesonqk commented 6 years ago

@suclogger Unable to compile 0.2.0, see this

image

and this,

image

Changing version to 2.5.10 or any other higher version doesn't seem to solve this problem, please help!

Thanks.

neesonqk commented 6 years ago

I searched around but, unfortunately there seems isn't a version 2.5.11 even existing on anywhere, we're trying to compile and integrate into our spring boot 2 project, any help will be much appreciated, thank you.

@suclogger @mercyblitz

suclogger commented 6 years ago

@neesonqk Please refer to #96 .

neesonqk commented 6 years ago

@suclogger thanks a ton! I'm able to compile now.

neesonqk commented 6 years ago

@suclogger I know it's quite annoying, but do you have any idea that once any changes applied to the working simple, it stops to work anymore.

I'm able to run your official simples (provider vs consumer) like a charm, however, I'd like to tweak that simple to work with my own scenario, the thing is, no matter how do I follow the exact simple, it never work even just the class name changes, I'm frustrated.

This is the exception:

com.alibaba.dubbo.remoting.RemotingException: Not found exported service: com.ont.palm.rpc.EchoService:1.0.0:12345 in [com.ont.messager.rpc.EchoService:1.0.0:12345], may be version or group mismatch , channel: consumer: /20.20.20.20:56722 --> provider: /20.20.20.20:12345, message:RpcInvocation [methodName=greet, parameterTypes=[], arguments=[], attachments={path=com.ont.palm.rpc.EchoService, input=153, dubbo=2.0.1, interface=com.ont.palm.rpc.EchoService, version=1.0.0}]
    at com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol.getInvoker(DubboProtocol.java:202)
    at com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol$1.reply(DubboProtocol.java:73)
    at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.handleRequest(HeaderExchangeHandler.java:96)
    at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.received(HeaderExchangeHandler.java:168)
    at com.alibaba.dubbo.remoting.transport.DecodeHandler.received(DecodeHandler.java:50)
    at com.alibaba.dubbo.remoting.transport.dispatcher.ChannelEventRunnable.run(ChannelEventRunnable.java:79)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
] with root cause

My provider and its interface:

image

image

Configuration:

# Spring boot application
spring.application.name = messager-provider-app
server.port = 9090

# DemoService service version
messager.service.version = 1.0.0

# Base packages to scan Dubbo Components (e.g @Service , @Reference)
dubbo.scan.basePackages  = com.ont.messager.rpc

# Dubbo Config properties
## ApplicationConfig Bean
dubbo.application.id = messager-provider
dubbo.application.name = messager-provider
#dubbo.application.qos.port=22222
#dubbo.application.qos.enable=true

## ProtocolConfig Bean
dubbo.protocol.id = dubbo
dubbo.protocol.name = dubbo
dubbo.protocol.port = 12345
dubbo.protocol.status = server

## RegistryConfig Bean
dubbo.registry.id = my-registry
dubbo.registry.address = N/A

My consumer:

image

# Spring boot application
spring.application.name = dubbo-consumer-demo
server.port = 8080
management.server.port = 8081

# DemoService service version
messager.service.version = 1.0.0

# Dubbo Config properties
## ApplicationConfig Bean
dubbo.application.id = dubbo-consumer-demo
dubbo.application.name = dubbo-consumer-demo

## Legacy QOS Config
dubbo.qos.port = 22223

## ProtocolConfig Bean
dubbo.protocol.id = dubbo
dubbo.protocol.name = dubbo
dubbo.protocol.port = 12345

# Dubbo Endpoint (default status is disable)
endpoints.dubbo.enabled = true

Any idea? Thanks a lot.

suclogger commented 6 years ago

@neesonqk As far as I can see, maybe you didn't start provider before your try to consume?

neesonqk commented 6 years ago

@suclogger I'm very sure that I've started the provider ahead of the consumer. I'll try to reproduce the same problem from your official simples and tweat there, if encountered the same problem, I'll post up here tmr.

Thank you and much appreciated!

neesonqk commented 6 years ago

provider_and_consumer.zip

@suclogger I've modified your official example, just created a new interface and it's implementation, then comment out your DefaultDemoService, then it stopped to work anymore, please help to take a look, thank you!

neesonqk commented 6 years ago

I think I've found the problem, regarding the interface between provider and consumer, it has to be in the same package path, which means for both sides, assume MyInterface locates at A.B.C this package in provider, then it has to be placed to the excatly same structured package A.B.C in consumer as well. My problem is I put them into different paths, and those paths are part of the services looking for.

@suclogger Any best practices to organize/share the interfaces between providers and consumers?

suclogger commented 6 years ago

@neesonqk Usually, the interface class definition is published by provider as a maven dependency. Consumer should import the interface class rather than define it again himself.

neesonqk commented 6 years ago

Cool! @suclogger

mercyblitz commented 6 years ago

Checkout master and build source , please wait for our release in Apache repository.