dubbo-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From haiyang1985 (GitHub) <git...@apache.org>
Subject [GitHub] [incubator-dubbo] haiyang1985 opened issue #3778: Annotation mode cannot set service parameters in 2.7.0
Date Mon, 01 Apr 2019 03:55:55 GMT
- [ ] I have searched the [issues](https://github.com/apache/incubator-dubbo/issues) of this
repository and believe that this is not a duplicate.
- [ ] I have checked the [FAQ](https://github.com/apache/incubator-dubbo/blob/master/FAQ.md)
of this repository and believe that this is not a duplicate.

### Environment

* Dubbo version: 2.7.0
* Operating System version: mac
* Java version: 1.8

### Steps to reproduce this issue

1. Start dubbo provider in 2.7.0 SpringBoot Annotation mode
```
@SpringBootApplication
@DubboComponentScan
public class SpringBootProvider {
  public static void main(String[] args) {
    new EmbeddedZooKeeper(2181, false).start();
    SpringApplication.run(SpringBootProvider.class);
  }
}
```

2. set parameters as 2.5.10 for the ServiceBean.
```
@Service(parameters = {"key","value"})
public class DemoServiceImpl implements DemoService {

}
```
3. run SpringBootProvider to start the service

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

### Expected Result

The service has been started and register to zookeeper.

### Actual Result

It throws exception as below, service cannot be started up.

```
Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property
value of type 'java.lang.String[]' to required type 'java.util.Map' for property 'parameters';
nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.lang.String[]'
to required type 'java.util.Map' for property 'parameters': no matching editors or conversion
strategy found
	at org.springframework.beans.AbstractNestablePropertyAccessor.convertIfNecessary(AbstractNestablePropertyAccessor.java:591)
~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
	at org.springframework.beans.AbstractNestablePropertyAccessor.convertForProperty(AbstractNestablePropertyAccessor.java:603)
~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
	at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:216)
~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1532)
~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1491)
~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1231)
~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:551)
~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
	... 15 more
Caused by: java.lang.IllegalStateException: Cannot convert value of type 'java.lang.String[]'
to required type 'java.util.Map' for property 'parameters': no matching editors or conversion
strategy found
	at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:306)
~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
	at org.springframework.beans.AbstractNestablePropertyAccessor.convertIfNecessary(AbstractNestablePropertyAccessor.java:576)
~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
	at org.springframework.beans.AbstractNestablePropertyAccessor.convertForProperty(AbstractNestablePropertyAccessor.java:603)
~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
	at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:216)
~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1532)
~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1491)
~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1231)
~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:551)
~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
	... 15 more
```

With my investigation, ConstructorArgValue discard in ServiceAnnotationBeanPostProcessor,
which caused the issue. 
```
private AbstractBeanDefinition buildServiceBeanDefinition(Service service, Class<?>
interfaceClass,
                                                              String annotatedServiceBeanName)
{

        BeanDefinitionBuilder builder = rootBeanDefinition(ServiceBean.class)
                .addConstructorArgValue(service)
                // References "ref" property to annotated-@Service Bean
                .addPropertyReference("ref", annotatedServiceBeanName)
                .addPropertyValue("interface", interfaceClass.getName());
}
```

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3778 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


Mime
View raw message