Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prepare中缺少对静态文件配置的说明 #22

Closed
NoComments opened this issue Jan 10, 2020 · 7 comments
Closed

prepare中缺少对静态文件配置的说明 #22

NoComments opened this issue Jan 10, 2020 · 7 comments

Comments

@NoComments
Copy link

No description provided.

@liubao68
Copy link
Contributor

你的意思是指南里面的没有说明 microservice.yaml 中需要正确配置静态页面的路径吗? 即 修改如下配置项:

gateway.webroot: /code/servicecomb-fence/samples/EdgeService/src/main/resources

@lyflyy
Copy link

lyflyy commented Jun 11, 2020

能否告知gateway.webroot 到底指向哪

@liubao68
Copy link
Contributor

即静态页面相关的文件所在的目录,比如: servicecomb-fence/samples/EdgeService/src/main/resources/ui, 可以查看 microservice.yamlStaticWebpageDispatcher

@lyflyy
Copy link

lyflyy commented Jun 12, 2020

在项目中pom文件的配置是这样的

<dependencies>
        <dependency>
            <groupId>org.apache.servicecomb</groupId>
            <artifactId>java-chassis-spring-boot-starter-servlet</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.servicecomb</groupId>
            <artifactId>edge-core</artifactId>
        </dependency>
    </dependencies>

配置文件中没有去声明[gateway.webroot]
image
请求地址:http://localhost:9090/ui/login.html
抛异常

java.lang.IllegalStateException: Request has already been read
	at io.vertx.core.http.impl.HttpServerRequestImpl.checkEnded(HttpServerRequestImpl.java:600) ~[vertx-core-3.8.3.jar:3.8.3]
	at io.vertx.core.http.impl.HttpServerRequestImpl.handler(HttpServerRequestImpl.java:307) ~[vertx-core-3.8.3.jar:3.8.3]
	at io.vertx.ext.web.impl.HttpServerRequestWrapper.handler(HttpServerRequestWrapper.java:78) ~[vertx-web-3.8.3.jar:3.8.3]
	at org.apache.servicecomb.transport.rest.vertx.RestBodyHandler.handle(RestBodyHandler.java:102) ~[transport-rest-vertx-2.0.0.jar:2.0.0]
	at org.apache.servicecomb.transport.rest.vertx.RestBodyHandler.handle(RestBodyHandler.java:56) ~[transport-rest-vertx-2.0.0.jar:2.0.0]
	at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:986) ~[vertx-web-3.8.3.jar:3.8.3]
	at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:131) ~[vertx-web-3.8.3.jar:3.8.3]
	at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:130) ~[vertx-web-3.8.3.jar:3.8.3]
	at io.vertx.ext.web.handler.impl.StaticHandlerImpl.lambda$sendStatic$1(StaticHandlerImpl.java:206) ~[vertx-web-3.8.3.jar:3.8.3]
	at io.vertx.core.impl.ContextImpl.lambda$null$0(ContextImpl.java:330) ~[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$$$capture(AbstractEventExecutor.java:164) ~[netty-common-4.1.45.Final.jar:4.1.45.Final]
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java) ~[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_191]

不知道gateway.webroot需要怎么设置才能正常访问到静态资源,示例项目直接启动也是有这个错误,bmi、porter都是这个异常

@liubao68
Copy link
Contributor

配置项在 microservice.yaml 或者 application.yml 里面

gateway:
  webroot: /code/servicecomb-samples/porter_lightweight/gateway-service/src/main/resources

sample里面的配置是 windows 配置。 表示当前磁盘,比如 D。

@lyflyy
Copy link

lyflyy commented Jun 12, 2020

image
不如我这样问您,mac系统 启动
gateway.webroot应该配置为什么?
相对路径的根目录是static吗,还是要配置绝对路径,绝对路径要抛

root cannot start with / 

异常,相对路径

Request has already been read

不如您直接告诉我mac下应该怎么配置吧

@liubao68
Copy link
Contributor

liubao68 commented Jun 13, 2020

mac 或者 linux 配置的是相对路径。 如果你已经尝试,并且还是报错, 可以试着调试下代码。看看为什么没有查找到页面文件,具体调试的类就是下面代码演示的 StaticHandler的handle方法。

@Override
  public void init(Router router) {
    String regex = "/ui/(.*)";
    StaticHandler webpageHandler = StaticHandler.create();
    webpageHandler.setWebRoot(WEB_ROOT);
    LOGGER.info("server static web page for WEB_ROOT={}", WEB_ROOT);
    router.routeWithRegex(regex).failureHandler((context) -> {
      LOGGER.error("", context.failure());
    }).handler(webpageHandler);
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants