9 Replies Latest reply on Jan 15, 2014 7:07 AM by garcia-jj

    Beta 1 - Error when use wrapped HttpServletRequest

    garcia-jj

      I need to wrap HttpServletRequest and HttpServletResponse in my application. When I use JBoss AS 7.1 all works fine. But testing my application with Wildfly beta 1, I got this error:

       

      java.lang.IllegalArgumentException: UT010023: Request [CustomRequest io.undertow.servlet.spec.HttpServletRequestImpl@4f519a0a] was not original or a wrapper

       

      What's wrong?

        • 1. Re: Beta 1 - Error when use wrapped HttpServletRequest
          swd847

          According to the servlet spec your wrapper *must* extend javax.servlet.ServletRequestWrapper (or its sub class javax.servlet.http.HttpServletRequestWrapper). This behaviour is tested by the TCK, so we cannot disable this behaviour in our default configs.

           

          To disable this check you must add an allow-non-standard-wrappers="true" attribute to the servlet-container element in the undertow subsystem.

          • 2. Re: Beta 1 - Error when use wrapped HttpServletRequest
            garcia-jj

            It's very strange, because my classes are *ServletRequestWrapper.

             

            My class is:

            public class CustomRequest extends HttpServletRequestWrapper implements MutableRequest { } 

            And MutableRequest is an interface that extends HttpServletRequest:

             

            public interface MutableRequest extends HttpServletRequest { }

            It's right, or I need to change anything here? May be undertow are confused because my CustomRequest is MutableRequest that is HttpServletRequest?

             

            Thank you, Stuart Douglas.

            • 3. Re: Beta 1 - Error when use wrapped HttpServletRequest
              swd847

              Can you paste the full stack trace?

              • 4. Re: Re: Beta 1 - Error when use wrapped HttpServletRequest
                garcia-jj

                See bellow. You can see custom request object here:

                 

                MutableRequest: https://github.com/caelum/vraptor4/blob/master/vraptor-core/src/main/java/br/com/caelum/vraptor/http/MutableRequest.java#L26

                VRaptorRequest (the custom request that undertown throws exception) https://github.com/caelum/vraptor4/blob/master/vraptor-core/src/main/java/br/com/caelum/vraptor/http/VRaptorRequest.java#L41

                 

                Complete stack trace: https://gist.github.com/garcia-jj/8131829

                 

                Caused by: java.lang.IllegalArgumentException: UT010023: Request [VRaptorRequest io.undertow.servlet.spec.HttpServletRequestImpl@7353039f] was not original or a wrapper

                    at io.undertow.servlet.spec.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:102) [undertow-servlet-1.0.0.Beta30.jar:1.0.0.Beta30]

                    at br.com.caelum.vraptor.view.DefaultPageResult.defaultView(DefaultPageResult.java:77) [vraptor-4.0.0-beta-4-SNAPSHOT.jar:]

                    at br.com.caelum.vraptor.observer.ForwardToDefaultView.forward(ForwardToDefaultView.java:65) [vraptor-4.0.0-beta-4-SNAPSHOT.jar:]

                    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_13]

                    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_13]

                    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_13]

                    at java.lang.reflect.Method.invoke(Method.java:601) [rt.jar:1.7.0_13]

                    at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:93) [weld-core-impl-2.1.1.Final.jar:2013-12-03 09:59]

                    at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:266) [weld-core-impl-2.1.1.Final.jar:2013-12-03 09:59]

                    at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:253) [weld-core-impl-2.1.1.Final.jar:2013-12-03 09:59]

                    at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:232) [weld-core-impl-2.1.1.Final.jar:2013-12-03 09:59]

                    at org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:169) [weld-core-impl-2.1.1.Final.jar:2013-12-03 09:59]

                    at org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:165) [weld-core-impl-2.1.1.Final.jar:2013-12-03 09:59]

                    at org.jboss.weld.event.TransactionalObserverNotifier.notifyObserver(TransactionalObserverNotifier.java:46) [weld-core-impl-2.1.1.Final.jar:2013-12-03 09:59]

                    at org.jboss.weld.event.ObserverNotifier.notifyObservers(ObserverNotifier.java:119) [weld-core-impl-2.1.1.Final.jar:2013-12-03 09:59]

                    at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:112) [weld-core-impl-2.1.1.Final.jar:2013-12-03 09:59]

                    at org.jboss.weld.event.EventImpl.fire(EventImpl.java:83) [weld-core-impl-2.1.1.Final.jar:2013-12-03 09:59]

                    at br.com.caelum.vraptor.observer.ExecuteMethod.execute(ExecuteMethod.java:108) [vraptor-4.0.0-beta-4-SNAPSHOT.jar:]

                • 5. Re: Re: Beta 1 - Error when use wrapped HttpServletRequest
                  swd847

                  Can you try with Wildfly CR1 and see if you still get the exception?

                  • 6. Re: Re: Beta 1 - Error when use wrapped HttpServletRequest
                    garcia-jj

                    Yes. I'm runing CR1 right now, and the same error occurs.

                    • 7. Re: Beta 1 - Error when use wrapped HttpServletRequest
                      garcia-jj

                      I'll check the undertow code to understand this behaviour. I belive that my code may be wrong, but I can see where.

                       

                      Thank you, Stuart Douglas.

                      • 8. Re: Beta 1 - Error when use wrapped HttpServletRequest
                        garcia-jj

                        Stuart Douglas, I tested the error again, and I have news.

                         

                        My wrapped request is produced by weld. So in the i.u.s.spec.RequestDispatcherImpl:105 I got this instance of request: org.jboss.weld.proxies.HttpServletRequest$MutableRequest$ServletRequest$157806845$Proxy$_$$_WeldClientProxy

                         

                        So the comparison will false.

                         

                        Do you have any idea how to solve this?

                         

                        Thank you

                        • 9. Re: Beta 1 - Error when use wrapped HttpServletRequest
                          garcia-jj

                          Stuart Douglas, I've changed the producer from RequestScoped to Dependend, and now works fine.

                           

                          Thank you very much.