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/06/05 07:06:02 UTC

[GitHub] [servicecomb-java-chassis] Arvinxiaoweihao opened a new issue #1237: @RpcSchema注册失败而换成@RestSchema后正常

Arvinxiaoweihao opened a new issue #1237: @RpcSchema注册失败而换成@RestSchema后正常
URL: https://github.com/apache/servicecomb-java-chassis/issues/1237
 
 
   @RestController
   //@RpcSchema(schemaId = "a")
   @RestSchema(schemaId = "a")
   @RequestMapping("a")
   public class AController implements IARest {
   //some method
   }
   代码修改后如上,这样才能启动正常,如果用的是@RpcSchema 则启动报错如下:
   
   Caused by: org.apache.servicecomb.foundation.common.exceptions.ServiceCombException: operation with url /a/getAById/, method GET is duplicated.
   	at org.apache.servicecomb.common.rest.locator.MicroservicePaths.addStaticPathResource(MicroservicePaths.java:81)
   	at org.apache.servicecomb.common.rest.locator.MicroservicePaths.addResource(MicroservicePaths.java:57)
   	at org.apache.servicecomb.common.rest.locator.ServicePathManager.addResource(ServicePathManager.java:121)
   	at org.apache.servicecomb.common.rest.locator.ServicePathManager.addSchema(ServicePathManager.java:88)
   	at org.apache.servicecomb.common.rest.RestEngineSchemaListener.onSchemaLoaded(RestEngineSchemaListener.java:54)
   	at org.apache.servicecomb.core.definition.loader.SchemaListenerManager.notifySchemaListener(SchemaListenerManager.java:59)
   	at org.apache.servicecomb.core.definition.loader.SchemaListenerManager.notifySchemaListener(SchemaListenerManager.java:48)
   	at org.apache.servicecomb.core.definition.loader.SchemaListenerManager.notifySchemaListener(SchemaListenerManager.java:54)
   	at org.apache.servicecomb.core.SCBEngine.doInit(SCBEngine.java:246)
   	at org.apache.servicecomb.core.SCBEngine.init(SCBEngine.java:206)
   
   发现在MicroservicePaths这个类中抛出了重复路径问题,如下是代码
   
   protected void addStaticPathResource(RestOperationMeta operation) {
       String httpMethod = operation.getHttpMethod();
       String path = operation.getAbsolutePath();
       OperationGroup group = staticPathOperations.get(path);
       if (group == null) {
         group = new OperationGroup();
         group.register(httpMethod, operation);
         staticPathOperations.put(path, group);
         return;
       }
   
       if (group.findValue(httpMethod) == null) {
         group.register(httpMethod, operation);
         return;
       }
   
       throw new ServiceCombException(
           String.format("operation with url %s, method %s is duplicated.", path, httpMethod));
     }

----------------------------------------------------------------
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