8 Replies Latest reply on Jun 19, 2014 8:29 PM by James Livingston

    Undertow occasionaly throws 400 BAD_REQUEST errors

    Vered Rosen Newbie

      We use WildFly 8.0 version for our server on Windows 7.

      Our client issues REST requests to the server every 5 seconds and once in a while we get BAD_REQUEST responses.

      After enabling debug logs of both Undertow and RESTEasy we see that Undertow throws the below exceptions at the same time we get the BAD_REQUEST responses:

       

      2014-05-15 11:33:41,692 DEBUG [io.undertow.request.io] (default I/O-2) UT005014: Failed to parse HTTP request: java.lang.RuntimeException: Invalid character

        at io.undertow.server.protocol.http.HttpRequestParser$$generated.handleHttpVerb(Unknown Source)

        at io.undertow.server.protocol.http.HttpRequestParser.handle(HttpRequestParser.java:210)

        at io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:131)

        at io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:46)

        at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92) [xnio-api-3.2.0.Final.jar:3.2.0.Final]

        at org.xnio.conduits.ReadReadyHandler$ChannelListenerHandler.readReady(ReadReadyHandler.java:66) [xnio-api-3.2.0.Final.jar:3.2.0.Final]

        at org.xnio.nio.NioSocketConduit.handleReady(NioSocketConduit.java:87) [xnio-nio-3.2.0.Final.jar:3.2.0.Final]

        at org.xnio.nio.WorkerThread.run(WorkerThread.java:531) [xnio-nio-3.2.0.Final.jar:3.2.0.Final]

       

      And:

      2014-05-15 06:43:55,085 DEBUG [io.undertow.request.io] (default I/O-1) UT005014: Failed to parse HTTP request: java.lang.IndexOutOfBoundsException

        at java.nio.Buffer.checkIndex(Buffer.java:532) [rt.jar:1.7.0_03]

        at java.nio.DirectByteBuffer.get(DirectByteBuffer.java:253) [rt.jar:1.7.0_03]

        at io.undertow.server.protocol.http.HttpRequestParser.handleCachedHeader(HttpRequestParser.java:759)

        at io.undertow.server.protocol.http.HttpRequestParser.handleHeaderValue(HttpRequestParser.java:634)

        at io.undertow.server.protocol.http.HttpRequestParser.handle(HttpRequestParser.java:253)

        at io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:131)

        at io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:46)

        at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92) [xnio-api-3.2.0.Final.jar:3.2.0.Final]

        at org.xnio.conduits.ReadReadyHandler$ChannelListenerHandler.readReady(ReadReadyHandler.java:66) [xnio-api-3.2.0.Final.jar:3.2.0.Final]

        at org.xnio.nio.NioSocketConduit.handleReady(NioSocketConduit.java:87) [xnio-nio-3.2.0.Final.jar:3.2.0.Final]

        at org.xnio.nio.WorkerThread.run(WorkerThread.java:531) [xnio-nio-3.2.0.Final.jar:3.2.0.Final]

       

       

      The requests are not passed at all to the RESTEasy layer,

      Searching the internet for these errors yield no results.

      From WireShark the request packets look ok.

      Tried to reproduce the problem using a firefox that is configured to work in Http/1.0 - the problem does not occur.

      However working with Http/1.0 is not an option for us.

      Does anyone have any idea to what the problem may be?

        • 1. Re: Undertow occasionaly throws 400 BAD_REQUEST errors
          Tomaz Cerar Master

          Please try with 8.1.0.CR2 as it we addressed lots of Undertow related problems in 8.1.

          And let us know if this fixes problem for you.

          • 2. Re: Undertow occasionaly throws 400 BAD_REQUEST errors
            Vered Rosen Newbie

            We tried, but failed the upgrade.

            With 8.1.0.CR2 we get the following exception when we send REST requests to the server:


            Caused by: java.lang.NullPointerException

            at org.jboss.resteasy.plugins.server.servlet.HttpServletResponseHeaders.addResponseHeader(HttpServletResponseHeaders.java:87) [resteasy-jaxrs-3.0.8.Final.jar:]

            at org.jboss.resteasy.plugins.server.servlet.HttpServletResponseHeaders.add(HttpServletResponseHeaders.java:82) [resteasy-jaxrs-3.0.8.Final.jar:]

            at org.jboss.resteasy.plugins.server.servlet.HttpServletResponseHeaders.putAll(HttpServletResponseHeaders.java:151) [resteasy-jaxrs-3.0.8.Final.jar:]

            at org.jboss.resteasy.core.ServerResponseWriter.commitHeaders(ServerResponseWriter.java:235) [resteasy-jaxrs-3.0.8.Final.jar:]

            at org.jboss.resteasy.core.ServerResponseWriter$1.commit(ServerResponseWriter.java:81) [resteasy-jaxrs-3.0.8.Final.jar:]

            at org.jboss.resteasy.util.CommitHeaderOutputStream.commit(CommitHeaderOutputStream.java:50) [resteasy-jaxrs-3.0.8.Final.jar:]

            at org.jboss.resteasy.util.CommitHeaderOutputStream.write(CommitHeaderOutputStream.java:70) [resteasy-jaxrs-3.0.8.Final.jar:]

            at com.fasterxml.jackson.core.json.UTF8JsonGenerator._flushBuffer(UTF8JsonGenerator.java:1862) [jackson-core-2.3.2.jar:2.3.2]

            at com.fasterxml.jackson.core.json.UTF8JsonGenerator.flush(UTF8JsonGenerator.java:1056) [jackson-core-2.3.2.jar:2.3.2]

            at com.fasterxml.jackson.databind.ObjectWriter.writeValue(ObjectWriter.java:615) [jackson-databind-2.3.2.jar:2.3.2]

            at org.jboss.resteasy.plugins.providers.jackson.ResteasyJackson2Provider.writeTo(ResteasyJackson2Provider.java:186) [resteasy-jackson2-provider-3.0.8.Final.jar:]

            at org.jboss.resteasy.core.interception.AbstractWriterInterceptorContext.writeTo(AbstractWriterInterceptorContext.java:129) [resteasy-jaxrs-3.0.8.Final.jar:]

            at org.jboss.resteasy.core.interception.ServerWriterInterceptorContext.writeTo(ServerWriterInterceptorContext.java:62) [resteasy-jaxrs-3.0.8.Final.jar:]

            at org.jboss.resteasy.core.interception.AbstractWriterInterceptorContext.proceed(AbstractWriterInterceptorContext.java:118) [resteasy-jaxrs-3.0.8.Final.jar:]

            at org.jboss.resteasy.security.doseta.DigitalSigningInterceptor.aroundWriteTo(DigitalSigningInterceptor.java:143) [resteasy-crypto-3.0.8.Final.jar:]

            at org.jboss.resteasy.core.interception.AbstractWriterInterceptorContext.proceed(AbstractWriterInterceptorContext.java:122) [resteasy-jaxrs-3.0.8.Final.jar:]

            at org.jboss.resteasy.plugins.interceptors.encoding.GZIPEncodingInterceptor.aroundWriteTo(GZIPEncodingInterceptor.java:100) [resteasy-jaxrs-3.0.8.Final.jar:]

            at org.jboss.resteasy.core.interception.AbstractWriterInterceptorContext.proceed(AbstractWriterInterceptorContext.java:122) [resteasy-jaxrs-3.0.8.Final.jar:]

            at org.jboss.resteasy.core.ServerResponseWriter.writeNomapResponse(ServerResponseWriter.java:99) [resteasy-jaxrs-3.0.8.Final.jar:]

            at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:153) [resteasy-jaxrs-3.0.8.Final.jar:]

            ... 43 more

            • 3. Re: Undertow occasionaly throws 400 BAD_REQUEST errors
              Vered Rosen Newbie

              I looked at release notes - do you know of any specific bug fixed in 8.1.0.CR2 that may have had anything to do with the issue I am seeing?

              • 4. Re: Undertow occasionaly throws 400 BAD_REQUEST errors
                Tomaz Cerar Master

                This should now be fixed in Undertow 1.0.14.Final.

                 

                you can manually replace it in your CR2 instantiation, or build 8.x branch of WildFly.

                • 5. Re: Undertow occasionaly throws 400 BAD_REQUEST errors
                  Vered Rosen Newbie

                  Ok, thanks.

                  Do you know whether it should be part of CR3?

                  • 6. Re: Undertow occasionaly throws 400 BAD_REQUEST errors
                    Alisson Savoini Dias Newbie

                    I'm having the exactly same problem, only that 99% of my RESTEASY calls are ending with error 500.

                    My environment is: CentOS 6.5 latest, Wildfly 8.1.0 Final, my apps are compiled with Oracle Java JRE 1.7.0 release 55. Wildfly is executing with OpenJDK 1.7.0 release 55.

                    Even when I try to access a POST method using GET, where it should just show me a cute 500 error page, it actually shows me "Internal Server Error" and prints this trace in the console:

                     

                    2014-06-19 15:18:11,476 WARN  [org.jboss.resteasy.core.ExceptionHandler] (default task-27) failed to execute: javax.ws.rs.NotAllowedException: No resource method found for GET, return 405 with Allow header

                            at org.jboss.resteasy.core.registry.SegmentNode.match(SegmentNode.java:375) [resteasy-jaxrs-3.0.8.Final.jar:]

                            at org.jboss.resteasy.core.registry.SegmentNode.match(SegmentNode.java:114) [resteasy-jaxrs-3.0.8.Final.jar:]

                            at org.jboss.resteasy.core.registry.RootNode.match(RootNode.java:43) [resteasy-jaxrs-3.0.8.Final.jar:]

                            at org.jboss.resteasy.core.registry.RootClassNode.match(RootClassNode.java:48) [resteasy-jaxrs-3.0.8.Final.jar:]

                            at org.jboss.resteasy.core.ResourceMethodRegistry.getResourceInvoker(ResourceMethodRegistry.java:444) [resteasy-jaxrs-3.0.8.Final.jar:]

                            at org.jboss.resteasy.core.SynchronousDispatcher.getInvoker(SynchronousDispatcher.java:234) [resteasy-jaxrs-3.0.8.Final.jar:]

                            at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:171) [resteasy-jaxrs-3.0.8.Final.jar:]

                            at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:220) [resteasy-jaxrs-3.0.8.Final.jar:]

                            at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56) [resteasy-jaxrs-3.0.8.Final.jar:]

                            at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51) [resteasy-jaxrs-3.0.8.Final.jar:]

                            at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) [jboss-servlet-api_3.1_spec-1.0.0.Final.jar:1.0.0.Final]

                            at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85) [undertow-servlet-1.0.15.Final.jar:1.1.0.Beta2]

                            at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:61) [undertow-servlet-1.0.15.Final.jar:1.1.0.Beta2]

                            at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) [undertow-servlet-1.0.15.Final.jar:1.1.0.Beta2]

                            at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)

                            at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.0.15.Final.jar:1.1.0.Beta2]

                            at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131) [undertow-servlet-1.0.15.Final.jar:1.1.0.Beta2]

                            at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:56) [undertow-servlet-1.0.15.Final.jar:1.1.0.Beta2]

                            at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.0.15.Final.jar:1.1.0.Beta2]

                            at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:45) [undertow-core-1.0.15.Final.jar:1.1.0.Beta2]

                            at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:61) [undertow-servlet-1.0.15.Final.jar:1.1.0.Beta2]

                            at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58) [undertow-core-1.0.15.Final.jar:1.1.0.Beta2]

                            at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70) [undertow-servlet-1.0.15.Final.jar:1.1.0.Beta2]

                            at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76) [undertow-core-1.0.15.Final.jar:1.1.0.Beta2]

                            at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.0.15.Final.jar:1.1.0.Beta2]

                            at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)

                            at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.0.15.Final.jar:1.1.0.Beta2]

                            at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.0.15.Final.jar:1.1.0.Beta2]

                            at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:243) [undertow-servlet-1.0.15.Final.jar:1.1.0.Beta2]

                            at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:230) [undertow-servlet-1.0.15.Final.jar:1.1.0.Beta2]

                            at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:76) [undertow-servlet-1.0.15.Final.jar:1.1.0.Beta2]

                            at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:149) [undertow-servlet-1.0.15.Final.jar:1.1.0.Beta2]

                            at io.undertow.server.Connectors.executeRootHandler(Connectors.java:195) [undertow-core-1.0.15.Final.jar:1.1.0.Beta2]

                            at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:733) [undertow-core-1.0.15.Final.jar:1.1.0.Beta2]

                            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_55]

                            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_55]

                            at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_55]

                     

                     

                    2014-06-19 15:18:11,482 ERROR [io.undertow.request] (default task-27) UT005023: Exception handling request to /isa/apis/authentication/logon/persistent: org.jboss.resteasy.spi.UnhandledException: java.lang.NullPointerException

                            at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:157) [resteasy-jaxrs-3.0.8.Final.jar:]

                            at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:176) [resteasy-jaxrs-3.0.8.Final.jar:]

                            at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:220) [resteasy-jaxrs-3.0.8.Final.jar:]

                            at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56) [resteasy-jaxrs-3.0.8.Final.jar:]

                            at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51) [resteasy-jaxrs-3.0.8.Final.jar:]

                            at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) [jboss-servlet-api_3.1_spec-1.0.0.Final.jar:1.0.0.Final]

                            at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85) [undertow-servlet-1.0.15.Final.jar:1.1.0.Beta2]

                            at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:61) [undertow-servlet-1.0.15.Final.jar:1.1.0.Beta2]

                            at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) [undertow-servlet-1.0.15.Final.jar:1.1.0.Beta2]

                            at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)

                            at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.0.15.Final.jar:1.1.0.Beta2]

                            at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131) [undertow-servlet-1.0.15.Final.jar:1.1.0.Beta2]

                            at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:56) [undertow-servlet-1.0.15.Final.jar:1.1.0.Beta2]

                            at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.0.15.Final.jar:1.1.0.Beta2]

                            at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:45) [undertow-core-1.0.15.Final.jar:1.1.0.Beta2]

                            at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:61) [undertow-servlet-1.0.15.Final.jar:1.1.0.Beta2]

                            at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58) [undertow-core-1.0.15.Final.jar:1.1.0.Beta2]

                            at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70) [undertow-servlet-1.0.15.Final.jar:1.1.0.Beta2]

                            at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76) [undertow-core-1.0.15.Final.jar:1.1.0.Beta2]

                            at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.0.15.Final.jar:1.1.0.Beta2]

                            at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)

                            at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.0.15.Final.jar:1.1.0.Beta2]

                            at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.0.15.Final.jar:1.1.0.Beta2]

                            at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:243) [undertow-servlet-1.0.15.Final.jar:1.1.0.Beta2]

                            at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:230) [undertow-servlet-1.0.15.Final.jar:1.1.0.Beta2]

                            at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:76) [undertow-servlet-1.0.15.Final.jar:1.1.0.Beta2]

                            at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:149) [undertow-servlet-1.0.15.Final.jar:1.1.0.Beta2]

                            at io.undertow.server.Connectors.executeRootHandler(Connectors.java:195) [undertow-core-1.0.15.Final.jar:1.1.0.Beta2]

                            at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:733) [undertow-core-1.0.15.Final.jar:1.1.0.Beta2]

                            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_55]

                            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_55]

                            at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_55]

                    Caused by: java.lang.NullPointerException

                            at org.jboss.resteasy.plugins.server.servlet.HttpServletResponseHeaders.addResponseHeader(HttpServletResponseHeaders.java:87) [resteasy-jaxrs-3.0.8.Final.jar:]

                            at org.jboss.resteasy.plugins.server.servlet.HttpServletResponseHeaders.add(HttpServletResponseHeaders.java:82) [resteasy-jaxrs-3.0.8.Final.jar:]

                            at org.jboss.resteasy.plugins.server.servlet.HttpServletResponseHeaders.putAll(HttpServletResponseHeaders.java:151) [resteasy-jaxrs-3.0.8.Final.jar:]

                            at org.jboss.resteasy.core.ServerResponseWriter.commitHeaders(ServerResponseWriter.java:235) [resteasy-jaxrs-3.0.8.Final.jar:]

                            at org.jboss.resteasy.core.ServerResponseWriter.writeNomapResponse(ServerResponseWriter.java:54) [resteasy-jaxrs-3.0.8.Final.jar:]

                            at org.jboss.re

                    • 7. Re: Undertow occasionaly throws 400 BAD_REQUEST errors
                      Alisson Savoini Dias Newbie

                      Okay, nevermind, it looks one of my ContainerResponseFilter was including a tag in the header which was null. But I think it should be treated and wildfly/resteasy/undertow should not throw a NPE, but some message that ease the debug.

                      • 8. Re: Undertow occasionaly throws 400 BAD_REQUEST errors
                        James Livingston Apprentice

                        Even when I try to access a POST method using GET, where it should just show me a cute 500 error page, it actually shows me "Internal Server Error" and prints this trace in the console:

                        I don't think it should give you a 500 error at all, that is for internal server problems not bad requests from the client. GETing a resource which only has a handler for POST should return "405 Method Not Allowed", as it's doing:

                        2014-06-19 15:18:11,476 WARN  [org.jboss.resteasy.core.ExceptionHandler] (default task-27) failed to execute: javax.ws.rs.NotAllowedException: No resource method found for GET, return 405 with Allow header