You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2019/04/19 07:02:13 UTC

[GitHub] [servicecomb-java-chassis] johnyannj opened a new issue #1186: 使用本地注册中心,自己调用自己,有一个类型转换的错误

johnyannj opened a new issue #1186: 使用本地注册中心,自己调用自己,有一个类型转换的错误
URL: https://github.com/apache/servicecomb-java-chassis/issues/1186
 
 
   使用-Dlocal.registry.file指定注册中心文件
   
   一个简单接口
   ```
   @RestSchema(schemaId = "helloId")
   @RequestMapping("/")
   public class HelloService {
   
       @RequestMapping(value = "/hello", method= RequestMethod.GET)
       public String hello(@PathVariable(name = "name") String name) {
           return name;
       }
   }
   ```
   简单配置
   ```
   APPLICATION_ID: helloTest #Application name
   service_description: #Service description
     name: hello #Microservice name
     version: 1.0.0 #Service version
   servicecomb:
     rest:
       address: 0.0.0.0:8080
   
   ```
   同一进程里,自己调用自己
   ```
    CseRestTemplate cseRestTemplate = new CseRestTemplate();
           String xiaoming = cseRestTemplate.getForObject("cse://hello/hello?name={}", String.class, "xiaoming");
   ```
   
   异常如下:
   ```
   java.lang.ClassCastException: org.apache.servicecomb.serviceregistry.consumer.MicroserviceVersion cannot be cast to org.apache.servicecomb.core.definition.MicroserviceVersionMeta
   
   	at org.apache.servicecomb.core.provider.consumer.ReferenceConfig.getMicroserviceMeta(ReferenceConfig.java:54)
   	at org.apache.servicecomb.provider.springmvc.reference.CseClientHttpRequest.createRequestMeta(CseClientHttpRequest.java:154)
   	at org.apache.servicecomb.provider.springmvc.reference.CseClientHttpRequest.execute(CseClientHttpRequest.java:138)
   	at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:734)
   	at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:669)
   	at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:310)
   	at com.huawei.nuwa.cse.test.HmacTest.test(HmacTest.java:25)
   	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   	at java.lang.reflect.Method.invoke(Method.java:498)
   	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
   	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
   	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
   	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services