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 2020/11/09 04:14:39 UTC
[GitHub] [servicecomb-java-chassis] Eyekneemm opened a new issue #2045: 基于spring的web项目,注册后Address后面无urlPrefix;注册成功但rpc调用404
Eyekneemm opened a new issue #2045:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2045
求大佬解答,非常感谢!
如图所示,有urlPrefix的是基于springboot的项目,定义了application-context;

想请教一下,如果项目仅使用了spring,可以通过什么方式使注册后有urlPrefix?
问题背景:
如果address用的端口与tomcat为同一端口,例如都为8080,通过另一个服务调用rpc接口时会出现404;而更换端口为8081,tomcat为8080时,rpc调用正常,对比后发现没有urlPrefix。如果此处不一致是否还会带来其他问题?
如果上述问题不是因为urlPrefix导致的,那应该如何解决?
----------------------------------------------------------------
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
[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #2045: 基于spring的web项目,注册后Address后面无urlPrefix;注册成功但rpc调用404
Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #2045:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2045#issuecomment-724681145
如果用 java-chassis , 是不会的, java-chassis 会根据运行环境自动判断增加 urlPrefix 或者 不增加, client不用感知。
出现 404 可能是你的服务并不是以 java-chassis 的方式注册的。 你可以试试直接通过 swagger 里面的 url 去访问provider的REST接口,看看是否404 (如果是 tomcat注册了 urlPrefix 的场景, url 应该是 swagger里面的 urlPrefix+url).
关于tomcat场景的集成参考: https://docs.servicecomb.io/java-chassis/zh_CN/using-java-chassis-in-spring-boot/introduction/
----------------------------------------------------------------
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
[GitHub] [servicecomb-java-chassis] Eyekneemm edited a comment on issue #2045: 基于spring的web项目,注册后Address后面无urlPrefix;注册成功但rpc调用404
Posted by GitBox <gi...@apache.org>.
Eyekneemm edited a comment on issue #2045:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2045#issuecomment-724656738
> urlPrefix 是 tomcat 等 web 容器的 context path。 如果使用 rest over vert.x , 没有这个 context path.
请问如果没有urlPrefix,会导致rpc调用404吗?我想要rest address的端口和tomcat使用同一个端口,可以怎么做?
----------------------------------------------------------------
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
[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #2045: 基于spring的web项目,注册后Address后面无urlPrefix;注册成功但rpc调用404
Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #2045:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2045#issuecomment-723813950
urlPrefix 是 tomcat 等 web 容器的 context path。 如果使用 rest over vert.x , 没有这个 context path.
----------------------------------------------------------------
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
[GitHub] [servicecomb-java-chassis] Eyekneemm commented on issue #2045: 基于spring的web项目,注册后Address后面无urlPrefix;注册成功但rpc调用404
Posted by GitBox <gi...@apache.org>.
Eyekneemm commented on issue #2045:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2045#issuecomment-724656738
> urlPrefix 是 tomcat 等 web 容器的 context path。 如果使用 rest over vert.x , 没有这个 context path.
请问如果没有urlPrefix,会导致rpc调用404吗?
----------------------------------------------------------------
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
[GitHub] [servicecomb-java-chassis] Eyekneemm commented on issue #2045: 基于spring的web项目,注册后Address后面无urlPrefix;注册成功但rpc调用404
Posted by GitBox <gi...@apache.org>.
Eyekneemm commented on issue #2045:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2045#issuecomment-725079841
> 你描述的场景比较复杂,很多部分我也无法理解。 需要保留老系统功能,比如 servlet 等, 可以采用 rest on servlet 的方式使用 java-chassis。 这个时候, java-chassis 自己就是一个 servlet, 这个servlet加载的时候,会自动扫描所有的 REST/RPC 接口,并注册契约信息。 你的其他的老 servlet 等,保持不变就可以了。
>
> rest on servlet 场景, 注册的 endpoint 里面一般始终有 urlPrifx 的, 如果没有,那么应该就是集成有误(即 java-chassis 另外启动了一个新的 vert.x http server)。
请问您说的这种方式有指导吗?
----------------------------------------------------------------
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
[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #2045: 基于spring的web项目,注册后Address后面无urlPrefix;注册成功但rpc调用404
Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #2045:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2045#issuecomment-725077980
你描述的场景比较复杂,很多部分我也无法理解。 需要保留老系统功能,比如 servlet 等, 可以采用 rest on servlet 的方式使用 java-chassis。 这个时候, java-chassis 自己就是一个 servlet, 这个servlet加载的时候,会自动扫描所有的 REST/RPC 接口,并注册契约信息。 你的其他的老 servlet 等,保持不变就可以了。
rest on servlet 场景, 注册的 endpoint 里面一般始终有 urlPrifx 的, 如果没有,那么应该就是集成有误(即 java-chassis 另外启动了一个新的 vert.x http server)。
----------------------------------------------------------------
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
[GitHub] [servicecomb-java-chassis] liubao68 edited a comment on issue #2045: 基于spring的web项目,注册后Address后面无urlPrefix;注册成功但rpc调用404
Posted by GitBox <gi...@apache.org>.
liubao68 edited a comment on issue #2045:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2045#issuecomment-723813950
urlPrefix 是 tomcat 等 web 容器的 context path。 如果使用 rest over vert.x , 没有这个 context path.
----------------------------------------------------------------
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
[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #2045: 基于spring的web项目,注册后Address后面无urlPrefix;注册成功但rpc调用404
Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #2045:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2045#issuecomment-725092674
你前面已经发过了 [指导文档](https://docs.servicecomb.io/java-chassis/zh_CN/transports/rest-over-servlet/), [例子](https://github.com/apache/servicecomb-samples/tree/master/java-chassis-deployment-samples)
----------------------------------------------------------------
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
[GitHub] [servicecomb-java-chassis] Eyekneemm closed issue #2045: 基于spring的web项目,注册后Address后面无urlPrefix;注册成功但rpc调用404
Posted by GitBox <gi...@apache.org>.
Eyekneemm closed issue #2045:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2045
----------------------------------------------------------------
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
[GitHub] [servicecomb-java-chassis] Eyekneemm commented on issue #2045: 基于spring的web项目,注册后Address后面无urlPrefix;注册成功但rpc调用404
Posted by GitBox <gi...@apache.org>.
Eyekneemm commented on issue #2045:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2045#issuecomment-725067844
> 如果用 java-chassis , 是不会的, java-chassis 会根据运行环境自动判断增加 urlPrefix 或者 不增加, client不用感知。
> 出现 404 可能是你的服务并不是以 java-chassis 的方式注册的。 你可以试试直接通过 swagger 里面的 url 去访问provider的REST接口,看看是否404 (如果是 tomcat注册了 urlPrefix 的场景, url 应该是 swagger里面的 urlPrefix+url).
>
> 关于tomcat场景的集成参考: https://docs.servicecomb.io/java-chassis/zh_CN/using-java-chassis-in-spring-boot/introduction/
感谢解答,我现在是老项目集成CSE,无法使用springboot,web.xml中的servlet和contextLoader因为需要集成老框架,无法变更,未使用指导文档中说明的方式;
我参考java-chassis-starter的自动部署写了@Configuration,成功注册上了,但是调用rpc接口时就发生了404,我这种方式应该是[指导文档](https://docs.servicecomb.io/java-chassis/zh_CN/transports/rest-over-servlet/)中的rest on servlet模式?
项目会打包成war包,现状是如果使用IDEA-tomcat直接部署,注册成功但调用404;如果在服务器上用tomcat部署,配置context,启动时会阻塞一段时间,最后注册失败。
我这种情况是否需要继承框架使用的servlet或contextLoader,然后在其中加入cse的相关代码?或者有什么方法可以解决我这个问题?
非常感谢耐心指导!
----------------------------------------------------------------
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
[GitHub] [servicecomb-java-chassis] Eyekneemm commented on issue #2045: 基于spring的web项目,注册后Address后面无urlPrefix;注册成功但rpc调用404
Posted by GitBox <gi...@apache.org>.
Eyekneemm commented on issue #2045:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2045#issuecomment-725141432
> 你前面已经发过了 [指导文档](https://docs.servicecomb.io/java-chassis/zh_CN/transports/rest-over-servlet/), [例子](https://github.com/apache/servicecomb-samples/tree/master/java-chassis-deployment-samples)
非常感谢!我结合例子和源码再看下
----------------------------------------------------------------
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