Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Request io.undertow.servlet.spec.HttpServletRequestImpl was not original or a wrapper

I try to forward the request to a JSP page from a Rest method in WildFly 8.1 but this throws an Exception:

Caused by: java.lang.IllegalArgumentException: UT010023: Request io.undertow.servlet.spec.HttpServletRequestImpl@88ad706 was not original or a wrapper
    at io.undertow.servlet.spec.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:103) [undertow-servlet-1.0.15.Final.jar:1.0.15.Final]
    at my.domain.RestResource.myRestMethod(RestResource.java:525) [classes:]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_51]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_51]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_51]
    at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_51]
    at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:137) [resteasy-jaxrs-3.0.8.Final.jar:]
    at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:296) [resteasy-jaxrs-3.0.8.Final.jar:]
    at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:250) [resteasy-jaxrs-3.0.8.Final.jar:]
    at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:237) [resteasy-jaxrs-3.0.8.Final.jar:]
    at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:356) [resteasy-jaxrs-3.0.8.Final.jar:]
    ... 31 more

The code:

@GET
@Path("/my-path")
public void myRestMethod(@Context final HttpServletResponse response,
        @Context final HttpServletRequest request) throws ServletException, IOException {

     RequestDispatcher dispatcher = request.getRequestDispatcher("/path/to/jsp");
     dispatcher.forward(request, response);
}

This code worked without problems in Jboss 7.1.

like image 314
V G Avatar asked Sep 03 '14 12:09

V G


1 Answers

I did not debug enough to understand why/when those checks have been added (apparently this is required by the Servlet specification), but there is an option in Undertow to disable it:

In the standalone/configuration/standalone.xml file change the servlet-container XML element so that it has the attribute allow-non-standard-wrappers="true".

For details, check the official documentation (the Servlet container configuration section).

like image 66
V G Avatar answered Nov 15 '22 06:11

V G