1 Reply Latest reply on Aug 25, 2015 10:44 AM by Marcin Cieślak

    PathHandler exception on index page access

    Marcin Cieślak Newbie

      I am using WildFly Full 10.0.0.Beta1, standalone server.

      I set up an EAR with several modules. The EAR is deployed to "/lams" context path.

      The main module uses ServletExtension to catch authentication URLs and do some magic.

       

      deploymentInfo.addOuterHandlerChainWrapper(new HandlerWrapper() {

         public HttpHandler wrap(final HttpHandler handler) {

              return Handlers.path(handler).addExactPath("/j_security_check", new HttpHandler() {

                   //magic

              });

      }});

       

      So a PathHandler is in use.

       

      When I access an exact resource, like this

      http://localhost:8080/lams/index.jsp

      everything works fine.

       

      When I access just the context path

      http://localhost:8080/lams

      PathHandler throws

      Exception handling request to /lams/: java.lang.StringIndexOutOfBoundsException: String index out of range: -4

       

      The reason for that is PathHandler.handleRequest() method.

      It expects exchange.requestPath to be a full path.

      But in the method

      exchange.requestPath = /lams/

      exchange.relativePath = /index.jsp

      When getting the substring is attempted in line #89, it does not take into account that requestPath is not the full path, just the "browser path", and causes the exception.

       

      I do not create the exchange object myself, of course. Its values are filled by Undertow. When I check the exchange object early, at

      ServletInitialHandler.handleRequest()

      bothrequestPath and relativePath are already filled as above.

       

      Is it a bug? Or something I could fix by proper configuration?

       

      Thanks in advance!

      Marcin