[
https://issues.apache.org/jira/browse/CXF-5575?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13913626#comment-13913626
]
Sergey Beryozkin commented on CXF-5575:
---------------------------------------
We are not getting side-tracked but doing a proper investigation of why the
extra "/" causes the advanced container which Jetty 9 is fail the redirect.
Your original test case is somewhat unrealistic, the default context is used,
this fact and the fact that Tomcat test and numerous Jetty tests in CXF just
work led me to believe this is a very isolated/edge issue specific to Jetty. I
have also offered you a reasonable workaround, to do with using a
redirect-servlet-path parameter.
FYI, the servlet path of the original request has nothing to do with forming
the redirect path. You may have a servlet listening on "/bar/*" but want a
default or JSP servlet take care of the redirect. The documentation is for the
end users of the Servlet API so I'm surprised the Jetty RequestDispatcher
implementation is so sensitive. The other point is that replacing "/" with ""
breaks CXF tests where a path info is null.
So on one hand, giving the sensitivity of the fix and the fact a good enough
workaround exists I'm not really willing to change anything in CXF. On the
other hand, because you have just confirmed Jetty 9 chokes on this "/" even
with the proper context, I'm thinking may be I just should do a minor fix and
be done, in the end of the day using 'redirect-servlet-path' is not there to
hide some internal redirect issues but actually facilitate the redirection to
some other servlets listening on some custom patterns.
We may be able to use "" if it is set to "/" by default and not set via the
redirect-servlet-path, and pathInfo is not null.
Sergey
> Extra slash ('/') is prefixed to redirect URL in "redirects-list"
> -----------------------------------------------------------------
>
> Key: CXF-5575
> URL: https://issues.apache.org/jira/browse/CXF-5575
> Project: CXF
> Issue Type: Bug
> Components: JAX-RS
> Affects Versions: 3.0.0-milestone2
> Environment: jetty 9.1.2
> Reporter: Aurius Bendikas
> Assignee: Sergey Beryozkin
> Priority: Blocker
> Fix For: 3.0.0, 2.7.11, 2.6.14
>
> Attachments: InsertTitleHere.png, pom.xml, test-project.zip
>
>
> Using jetty 9.1.2 and latest CXF SNAPSHOT.
> Exception is thrown if trying to load i.e. "index.jsp":
> javax.servlet.ServletException: RequestDispatcher for path /index.jsp has
> failed
> at
> org.apache.cxf.transport.servlet.AbstractHTTPServlet.redirect(AbstractHTTPServlet.java:364)
> ~[cxf-rt-transports-http-3.0.0-SNAPSHOT.jar:3.0.0.SNAPSHOT]
> at
> org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:274)
> ~[cxf-rt-transports-http-3.0.0-SNAPSHOT.jar:3.0.0.SNAPSHOT]
> at
> org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:211)
> ~[cxf-rt-transports-http-3.0.0-SNAPSHOT.jar:3.0.0.SNAPSHOT]
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
> ~[javax.servlet-api-3.1.0.jar:3.1.0]
> at
> org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:262)
> ~[cxf-rt-transports-http-3.0.0-SNAPSHOT.jar:3.0.0.SNAPSHOT]
> at
> org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:717)
> ~[jetty-servlet-9.1.2.v20140210.jar:9.1.2.v20140210]
> at
> org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1644)
> ~[jetty-servlet-9.1.2.v20140210.jar:9.1.2.v20140210]
> at
> ch.qos.logback.classic.selector.servlet.LoggerContextFilter.doFilter(LoggerContextFilter.java:70)
> ~[logback-classic-1.1.1.jar:na]
> at
> org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1615)
> ~[jetty-servlet-9.1.2.v20140210.jar:9.1.2.v20140210]
> at
> org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:550)
> [jetty-servlet-9.1.2.v20140210.jar:9.1.2.v20140210]
> at
> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
> [jetty-server-9.1.2.v20140210.jar:9.1.2.v20140210]
> at
> org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:568)
> [jetty-security-9.1.2.v20140210.jar:9.1.2.v20140210]
> at
> org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:221)
> [jetty-server-9.1.2.v20140210.jar:9.1.2.v20140210]
> at
> org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1112)
> [jetty-server-9.1.2.v20140210.jar:9.1.2.v20140210]
> at
> org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:479)
> [jetty-servlet-9.1.2.v20140210.jar:9.1.2.v20140210]
> at
> org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:183)
> [jetty-server-9.1.2.v20140210.jar:9.1.2.v20140210]
> at
> org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1046)
> [jetty-server-9.1.2.v20140210.jar:9.1.2.v20140210]
> at
> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
> [jetty-server-9.1.2.v20140210.jar:9.1.2.v20140210]
> at
> org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
> [jetty-server-9.1.2.v20140210.jar:9.1.2.v20140210]
> at org.eclipse.jetty.server.Server.handle(Server.java:459)
> [jetty-server-9.1.2.v20140210.jar:9.1.2.v20140210]
> at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:281)
> [jetty-server-9.1.2.v20140210.jar:9.1.2.v20140210]
> at
> org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:232)
> [jetty-server-9.1.2.v20140210.jar:9.1.2.v20140210]
> at
> org.eclipse.jetty.io.AbstractConnection$1.run(AbstractConnection.java:505)
> [jetty-io-9.1.2.v20140210.jar:9.1.2.v20140210]
> at
> org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:607)
> [jetty-util-9.1.2.v20140210.jar:9.1.2.v20140210]
> at
> org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:536)
> [jetty-util-9.1.2.v20140210.jar:9.1.2.v20140210]
> at java.lang.Thread.run(Thread.java:744) [na:1.7.0_51]
> I have done some debugging and looks like CXF is adding extra '/' to the
> beginning of redirect URL. That makes jetty jsp servlet return error that
> //index.jsp is not found.
> Servlet configuration:
> <servlet>
> <servlet-name>CXFServlet</servlet-name>
>
> <servlet-class>org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet</servlet-class>
> <init-param>
> <param-name>javax.ws.rs.Application</param-name>
>
> <param-value>net.aurius.guestlist.GuestListApplicationConfig</param-value>
> </init-param>
> <init-param>
> <param-name>redirects-list</param-name>
> <param-value>/(\w)+.jsp</param-value>
> </init-param>
> <init-param>
> <param-name>redirect-servlet-name</param-name>
> <param-value>jsp</param-value>
> </init-param>
> <init-param>
> <param-name>redirect-attributes</param-name>
> <param-value>javax.servlet.include.request_uri</param-value>
> </init-param>
> <load-on-startup>1</load-on-startup>
> </servlet>
> <servlet-mapping>
> <servlet-name>CXFServlet</servlet-name>
> <url-pattern>/*</url-pattern>
> </servlet-mapping>
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)