Closed richard1230 closed 3 years ago
I am a new , I do as the guides; I can't know the reason, Can anyone help me
In your logs there is an error:
java.lang.IllegalArgumentException: root cannot start with '/'
at io.vertx.ext.web.handler.impl.StaticHandlerImpl.setRoot(StaticHandlerImpl.java:615) ~[vertx-web-3.8.3.jar:3.8.3]
at io.vertx.ext.web.handler.impl.StaticHandlerImpl.setWebRoot(StaticHandlerImpl.java:478) ~[vertx-web-3.8.3.jar:3.8.3]
at org.apache.servicecomb.samples.bmi.StaticWebpageDispatcher.init(StaticWebpageDispatcher.java:45) ~[classes/:na]
at org.apache.servicecomb.transport.rest.vertx.RestServerVerticle.initDispatcher(RestServerVerticle.java:212) ~[transport-rest-vertx-2.0.0.jar:2.0.0]
at org.apache.servicecomb.transport.rest.vertx.RestServerVerticle.start(RestServerVert
Please check https://github.com/apache/servicecomb-samples/blob/master/java-chassis-samples/bmi/webapp/src/main/resources/application.yml, and should configure
# This is web root for windows server, change this path according to where you put your source code
gateway:
webroot: /code/servicecomb-samples/java-chassis-samples/bmi/webapp/src/main/resources/static
@liubao68 now I have modified this application.yml as follows:
gateway:
webroot: /Users/mac/IdeaProjects/servicecomb-gitee-samples/java-chassis-samples/bmi/webapp/src/main/resources/static
It still has the same error:
java.lang.IllegalArgumentException: root cannot start with '/'
at io.vertx.ext.web.handler.impl.StaticHandlerImpl.setRoot(StaticHandlerImpl.java:615) ~[vertx-web-3.8.3.jar:3.8.3]
at io.vertx.ext.web.handler.impl.StaticHandlerImpl.setWebRoot(StaticHandlerImpl.java:478) ~[vertx-web-3.8.3.jar:3.8.3]
at org.apache.servicecomb.samples.bmi.StaticWebpageDispatcher.init(StaticWebpageDispatcher.java:45) ~[classes/:na]
at org.apache.servicecomb.transport.rest.vertx.RestServerVerticle.initDispatcher(RestServerVerticle.java:212) ~[transport-rest-vertx-2.0.0.jar:2.0.0]
at org.apache.servicecomb.transport.rest.vertx.RestServerVerticle.start(RestServerVerticle.java:94) ~[transport-rest-vertx-2.0.0.jar:2.0.0]
at io.vertx.core.Verticle.start(Verticle.java:66) [vertx-core-3.8.3.jar:3.8.3]
at io.vertx.core.impl.DeploymentManager.lambda$doDeploy$8(DeploymentManager.java:556) [vertx-core-3.8.3.jar:3.8.3]
at io.vertx.core.impl.ContextImpl.executeTask(ContextImpl.java:369) ~[vertx-core-3.8.3.jar:3.8.3]
at io.vertx.core.impl.EventLoopContext.lambda$executeAsync$0(EventLoopContext.java:38) ~[vertx-core-3.8.3.jar:3.8.3]
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164) ~[netty-common-4.1.45.Final.jar:4.1.45.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472) ~[netty-common-4.1.45.Final.jar:4.1.45.Final]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500) ~[netty-transport-4.1.45.Final.jar:4.1.45.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) ~[netty-common-4.1.45.Final.jar:4.1.45.Final]
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.45.Final.jar:4.1.45.Final]
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.45.Final.jar:4.1.45.Final]
at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_241]
2020-09-16 10:25:34.736 ERROR 39200 --- [ntloop-thread-4] o.a.s.t.rest.vertx.RestServerVerticle :
java.lang.IllegalArgumentException: root cannot start with '/'
at io.vertx.ext.web.handler.impl.StaticHandlerImpl.setRoot(StaticHandlerImpl.java:615) ~[vertx-web-3.8.3.jar:3.8.3]
at io.vertx.ext.web.handler.impl.StaticHandlerImpl.setWebRoot(StaticHandlerImpl.java:478) ~[vertx-web-3.8.3.jar:3.8.3]
at org.apache.servicecomb.samples.bmi.StaticWebpageDispatcher.init(StaticWebpageDispatcher.java:45) ~[classes/:na]
at org.apache.servicecomb.transport.rest.vertx.RestServerVerticle.initDispatcher(RestServerVerticle.java:212) ~[transport-rest-vertx-2.0.0.jar:2.0.0]
at org.apache.servicecomb.transport.rest.vertx.RestServerVerticle.start(RestServerVerticle.java:94) ~[transport-rest-vertx-2.0.0.jar:2.0.0]
at io.vertx.core.Verticle.start(Verticle.java:66) [vertx-core-3.8.3.jar:3.8.3]
at io.vertx.core.impl.DeploymentManager.lambda$doDeploy$8(DeploymentManager.java:556) [vertx-core-3.8.3.jar:3.8.3]
at io.vertx.core.impl.ContextImpl.executeTask(ContextImpl.java:369) ~[vertx-core-3.8.3.jar:3.8.3]
at io.vertx.core.impl.EventLoopContext.lambda$executeAsync$0(EventLoopContext.java:38) ~[vertx-core-3.8.3.jar:3.8.3]
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164) ~[netty-common-4.1.45.Final.jar:4.1.45.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472) ~[netty-common-4.1.45.Final.jar:4.1.45.Final]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500) ~[netty-transport-4.1.45.Final.jar:4.1.45.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) ~[netty-common-4.1.45.Final.jar:4.1.45.Final]
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.45.Final.jar:4.1.45.Final]
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.45.Final.jar:4.1.45.Final]
at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_241]
2020-09-16 10:25:34.736 ERROR 39200 --- [tloop-thread-10] o.a.s.t.rest.vertx.RestServerVerticle :
the code is here
This message is clear and saying 'root cannot start with '/'', you can't specify a path starts with '/'.
This demo using vert.x as a static web page provider, it has this restrictions. In windows, should use '/xxx/' , but in Linux/Unix like systems should use relative path.
If this is not convinient, you can using a tomcat container to host the static pages as illustrated in https://github.com/apache/servicecomb-samples/tree/master/porter_springboot
also see this issue https://github.com/apache/servicecomb-samples/issues/53
why not change to relative path directly: ./src/main/resources/static
, this should be and hello-world , should be as easy as possible
@ddassio This version of vert.x do not support relative path in windows. And this example provide static pages in vert.x static server. In real application, you can use other web servers to host static web page, as demonstrated in https://github.com/apache/servicecomb-samples/tree/master/porter_springboot
descript: my system environment is MacOS 10.14.3
step to reproduce this issue: 1.
2.
3.
4.
Then the problem happened: