I am using Jetty version 9.3.5 to create ProxyServlet.
To do so, I am extending my class from
org.eclipse.jetty.proxy.ProxyServlet;
Unlike previous version, I do not get the method protected URI rewriteURI(HttpServletRequest request) to override. After reading through grepcode I am seeing something like the followings and used it:
@Override
protected String rewriteTarget(HttpServletRequest request) {
if (!validateDestination(request.getServerName(), request.getServerPort()))
return null;
String roleAlias = (String)request.getSession().getAttribute(ATTR_PROXY_ROLE_ALIAS);
String uri =request.getRequestURI();
String aliasedURI = getAliasedURI(request.getMethod(), uri, roleAlias);
return aliasedURI ;
}
I do not know if this is the correct method to override.
In web.xml I have few filters and this servlet defined. For Servlet I have defined like this:
<servlet>
<servlet-name>Proxy</servlet-name>
<servlet-class>com.company.MyProxyServlet</servlet-class>
<async-supported>true</async-supported>
</servlet>
<servlet-mapping>
<servlet-name>Proxy</servlet-name>
<url-pattern>/proxy/*</url-pattern>
</servlet-mapping>
But I get the following exception? Any idea? Do I need to do same thing for the filters? then how? or what else missing?
java.lang.IllegalStateException: !asyncSupported
at org.eclipse.jetty.server.Request.startAsync(Request.java:2224)
at org.eclipse.jetty.proxy.ProxyServlet.service(ProxyServlet.java:80)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at com.company.MyProxyServlet.service(MyProxyServlet.java:66)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:821)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1685)
at com.netiq.sentinel.elasticsearch.proxy.AuditFilter.doFilter(AuditFilter.java:104)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1668)
at com.netiq.sentinel.elasticsearch.proxy.SecurityFilter.doFilter(SecurityFilter.java:160)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1668)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:581)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1158)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:511)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1090)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:213)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:109)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:119)
at org.eclipse.jetty.server.Server.handle(Server.java:517)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:306)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:242)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:261)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
at org.eclipse.jetty.io.ssl.SslConnection.onFillable(SslConnection.java:192)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:261)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:75)
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceAndRun(ExecuteProduceConsume.java:213)
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:147)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572)
Any Help?
Note:- I found few other post related to this error but nowhere the rewriteTarget method is used. Everywhere rewriteURI is used and I do not find it with Jetty 9.3.5.
Please Help.