You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "hewguo (GitHub)" <gi...@apache.org> on 2019/02/10 08:43:04 UTC
[GitHub] [incubator-dubbo] hewguo opened issue #3445: dubbo2.7 中RestProtocol.java getContextPath实现方式更改后无法注册rest服务
2.7.0版本getContextPath方法:
```
protected String getContextPath(URL url) {
String contextPath = url.getPath();
return contextPath.endsWith("/") ? contextPath.substring(0,contextPath.length()-1) : contextPath;
}
```
无法将方法置入web容器中,退回2.6.5版本的方法:
```
protected String getContextPath(URL url) {
int pos = url.getPath().lastIndexOf("/");
return pos > 0 ? url.getPath().substring(0, pos) : "";
}
```
使用正常,两个方法应该不等价的。
[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3445 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [incubator-dubbo] javaql commented on issue #3445: dubbo2.7 中RestProtocol.java getContextPath实现方式更改后无法注册rest服务
Posted by "javaql (GitHub)" <gi...@apache.org>.
获取到的contextPath是错误的,自己改了下这个方法打了个包好用了:
```
protected String getContextPath(URL url) {
int pos = url.getPath().lastIndexOf("/");
return pos > 0 ? url.getPath().substring(0, pos) : "";
}
```
[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3445 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [incubator-dubbo] xfbxag commented on issue #3445: dubbo2.7 中RestProtocol.java getContextPath实现方式更改后无法注册rest服务
Posted by "xfbxag (GitHub)" <gi...@apache.org>.
遇到了同样的问题
[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3445 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [incubator-dubbo] chickenlj commented on issue #3445: dubbo2.7 中RestProtocol.java getContextPath实现方式更改后无法注册rest服务
Posted by "chickenlj (GitHub)" <gi...@apache.org>.
Thanks for the report, I will take a look at this issue.
[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3445 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [incubator-dubbo] kezhenxu94 commented on issue #3445: dubbo2.7 中RestProtocol.java getContextPath实现方式更改后无法注册rest服务
Posted by "kezhenxu94 (GitHub)" <gi...@apache.org>.
Related issue #2088
Verified. I can reproduce this issue using the sample in `https://github.com/apache/incubator-dubbo-samples/tree/master/dubbo-samples-rest`(changing the dubbo version to 2.7.1-SNAPSHOT), will take more investigation in it. So this may be a bug?
[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3445 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [incubator-dubbo] hewguo commented on issue #3445: dubbo2.7 中RestProtocol.java getContextPath实现方式更改后无法注册rest服务
Posted by "hewguo (GitHub)" <gi...@apache.org>.
一个最简单的rest例子:
```
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://dubbo.apache.org/schema/dubbo
http://dubbo.apache.org/schema/dubbo/dubbo.xsd">
<dubbo:application name="demo-provider" logger="slf4j"/>
<dubbo:registry address="zookeeper://127.0.0.1:2181"/>
<!-- use dubbo protocol to export service on port 20880 -->
<dubbo:protocol name="dubbo" port="20880"/>
<dubbo:protocol name="rest" port="8080" server="tomcat" />
<bean id="demoService" class="com.nbport.dubbo.rest.ServiceImpl"/>
<!-- declare the service interface to be exported -->
<dubbo:service interface="com.nbport.dubbo.rest.ServiceFacade" ref="demoService" protocol="rest"/>
</beans>
```
--------
```
@Path("demo")
public class ServiceImpl implements ServiceFacade {
@Override
@Path("hello")
@GET
public String hello() {
return "Hello World! ";
}
@Override
@GET
@Path("/error")
public String error() {
throw new RuntimeException();
}
}
```
使用2.7.0的代码,在浏览器上是访问不到http://localhost:8080/demo/hello页面的,而用2.6.5的代码是可以的。代码跟了一下,2.7的代码getContextPath会返回接口的类名,如:“com.nbport.dubbo.rest.ServiceFacade”,而本例中原来版本返回的是“”。
[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3445 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [incubator-dubbo] cvictory closed issue #3445: dubbo2.7 中RestProtocol.java getContextPath实现方式更改后无法注册rest服务
Posted by "cvictory (GitHub)" <gi...@apache.org>.
[ issue closed by cvictory ]
[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3445 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [incubator-dubbo] ZhaoLoON commented on issue #3445: dubbo2.7 中RestProtocol.java getContextPath实现方式更改后无法注册rest服务
Posted by "ZhaoLoON (GitHub)" <gi...@apache.org>.
遇到了同样的问题,希望可以尽快修复
[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3445 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [incubator-dubbo] kezhenxu94 commented on issue #3445: dubbo2.7 中RestProtocol.java getContextPath实现方式更改后无法注册rest服务
Posted by "kezhenxu94 (GitHub)" <gi...@apache.org>.
Related issue #2088
[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3445 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [incubator-dubbo] netsail commented on issue #3445: dubbo2.7 中RestProtocol.java getContextPath实现方式更改后无法注册rest服务
Posted by "netsail (GitHub)" <gi...@apache.org>.
dubbo2.7版本也遇到了同样的问题了。
failed to execute
javax.ws.rs.NotFoundException: Could not find resource for full path: http://xxxxx.com/rest/getxxx
at org.jboss.resteasy.core.registry.ClassNode.match(ClassNode.java:73)
at org.jboss.resteasy.core.registry.RootClassNode.match(RootClassNode.java:48)
at org.jboss.resteasy.core.ResourceMethodRegistry.getResourceInvoker(ResourceMethodRegistry.java:444)
at org.jboss.resteasy.core.SynchronousDispatcher.getInvoker(SynchronousDispatcher.java:234)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:171)
at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:220)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.dubbo.rpc.protocol.rest.DubboHttpServer$RestHandler.handle(DubboHttpServer.java:89)
at org.apache.dubbo.remoting.http.servlet.DispatcherServlet.service(DispatcherServlet.java:61)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:528)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1099)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:670)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3445 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [incubator-dubbo] javaql commented on issue #3445: dubbo2.7 中RestProtocol.java getContextPath实现方式更改后无法注册rest服务
Posted by "javaql (GitHub)" <gi...@apache.org>.
获取到的contextPath是错误的,自己改了下这个方法打了个包好用了
`
protected String getContextPath(URL url) {
int pos = url.getPath().lastIndexOf("/");
return pos > 0 ? url.getPath().substring(0, pos) : "";
}`
[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3445 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [incubator-dubbo] kezhenxu94 commented on issue #3445: dubbo2.7 中RestProtocol.java getContextPath实现方式更改后无法注册rest服务
Posted by "kezhenxu94 (GitHub)" <gi...@apache.org>.
Verified. I can reproduce this issue using the sample in `https://github.com/apache/incubator-dubbo-samples/tree/master/dubbo-samples-rest`(changing the dubbo version to 2.7.1-SNAPSHOT), will take more investigation in it.
[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3445 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org