Giter VIP home page Giter VIP logo

Comments (5)

purplefox avatar purplefox commented on July 17, 2024

Thanks. Do you have a reproducer?

from vertx-web.

ashertarno avatar ashertarno commented on July 17, 2024

not something to copy paste in here, but any attempt to use StaticServer.staticServer() handler on windows should fail due to this.

from vertx-web.

purplefox avatar purplefox commented on July 17, 2024

If you could put together a simple test that exhibits the issue it would be a lot easier for me to track this down.

from vertx-web.

ashertarno avatar ashertarno commented on July 17, 2024

ok. below is a simple server for static files handling. the static server reads files from /webRoot/web/
trying to call localhost:8888/web/example.html
on linux all works good, the static file is returned as expected. on windows i get 500, while debugging i see the exception the follows the code.

//==================

package just.playing.vertx;

import io.vertx.core.AbstractVerticle;
import io.vertx.core.AsyncResult;
import io.vertx.core.Future;
import io.vertx.core.http.HttpServer;
import io.vertx.core.http.HttpServerOptions;
import io.vertx.ext.apex.addons.Favicon;
import io.vertx.ext.apex.addons.StaticServer;
import io.vertx.ext.apex.core.FailureRoutingContext;
import io.vertx.ext.apex.core.Router;
import io.vertx.ext.apex.core.RoutingContext;

public class ApexVerticle extends AbstractVerticle {

public void start( Future<Void> startFuture ) {

    Router router = Router.router( vertx );

    router.route()
          .handler( Favicon.favicon() );

    router.routeWithRegex( "/web/*" )
          .handler( StaticServer.staticServer()
                                .setDirectoryListing( false ) )
          .failureHandler( ( FailureRoutingContext context ) -> {

              context.response()
                     .setStatusCode( 404 )
                     .end();
          } );

    router.route()
          .handler( ( RoutingContext context ) -> {

              context.fail( 404 );
          } );


    //server
    vertx.createHttpServer( new HttpServerOptions().setPort( 8888 ) )
         .requestHandler( router::accept )
         .listen( ( AsyncResult<HttpServer> event ) -> {
             System.out.println( "Server is up" );
         } );
}

}

//=====

on windows machine only:

java.nio.file.NoSuchFileException: C:\Users\atarno\apex-files\webroot%5cweb%5cexample.html
at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:79)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102)
at sun.nio.fs.WindowsFileCopy.copy(WindowsFileCopy.java:99)
at sun.nio.fs.WindowsFileSystemProvider.copy(WindowsFileSystemProvider.java:278)
at java.nio.file.Files.copy(Files.java:1274)
at io.vertx.core.impl.FileResolver.unpackFromFileURL(FileResolver.java:107)
at io.vertx.core.impl.FileResolver.resolveFile(FileResolver.java:89)
at io.vertx.core.impl.VertxImpl.resolveFile(VertxImpl.java:603)
at io.vertx.core.file.impl.FileSystemImpl$6.perform(FileSystemImpl.java:517)
at io.vertx.core.file.impl.FileSystemImpl$6.perform(FileSystemImpl.java:514)
at io.vertx.core.file.impl.FileSystemImpl.propsBlocking(FileSystemImpl.java:150)
at io.vertx.ext.apex.addons.impl.StaticServerImpl.getFileProps(StaticServerImpl.java:203)
at io.vertx.ext.apex.addons.impl.StaticServerImpl.handle(StaticServerImpl.java:160)
at io.vertx.ext.apex.addons.impl.StaticServerImpl.handle(StaticServerImpl.java:51)
at io.vertx.ext.apex.core.impl.RouteImpl.handleContext(RouteImpl.java:174)
at io.vertx.ext.apex.core.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:69)
at io.vertx.ext.apex.core.impl.RoutingContextImpl.next(RoutingContextImpl.java:94)
at io.vertx.ext.apex.addons.impl.FaviconImpl.handle(FaviconImpl.java:161)
at io.vertx.ext.apex.addons.impl.FaviconImpl.handle(FaviconImpl.java:33)
at io.vertx.ext.apex.core.impl.RouteImpl.handleContext(RouteImpl.java:174)
at io.vertx.ext.apex.core.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:69)
at io.vertx.ext.apex.core.impl.RoutingContextImpl.next(RoutingContextImpl.java:94)
at io.vertx.ext.apex.core.impl.RouterImpl.accept(RouterImpl.java:56)
...
at io.vertx.core.http.impl.ServerConnection.handleRequest(ServerConnection.java:253)
at io.vertx.core.http.impl.ServerConnection.processMessage(ServerConnection.java:355)
at io.vertx.core.http.impl.ServerConnection.handleMessage(ServerConnection.java:129)
at io.vertx.core.http.impl.HttpServerImpl$ServerHandler.createConnAndHandle(HttpServerImpl.java:569)
at io.vertx.core.http.impl.HttpServerImpl$ServerHandler.doMessageReceived(HttpServerImpl.java:495)
at io.vertx.core.http.impl.HttpServerImpl$ServerHandler.doMessageReceived(HttpServerImpl.java:429)
at io.vertx.core.http.impl.VertxHttpHandler.channelRead(VertxHttpHandler.java:76)
at io.vertx.core.net.impl.VertxHandler.channelRead(VertxHandler.java:131)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:161)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
at io.vertx.core.http.impl.cgbystrom.FlashPolicyHandler.channelRead(FlashPolicyHandler.java:69)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:787)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:130)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
at java.lang.Thread.run(Thread.java:745)

from vertx-web.

purplefox avatar purplefox commented on July 17, 2024

Ok, thanks. This should be fixed now (in vertx-core).

from vertx-web.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.