Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] org.eclipse.jetty.server.Request cannot be cast to org.eclipse.jetty.server.Request

Hi guys,
I'm using Jetty-9.3.5.
My web app includes a pretty simple Servlet, as shown as the below,
public class ServerPushServlet extends HttpServlet {

    protected void doGet(HttpServletRequest request,
            HttpServletResponse response) throws ServletException, IOException {
        System.out.println("request=" + request);
        Request baseRequest = (Request) request;
        System.out.println("baseRequest=" + baseRequest);
    }
}

When I try to access this Servlet via browser, the output in console is the below,
request=Request(GET //localhost:9020/push/primary)@63206451
2015-12-30 19:47:11.471:WARN:oejs.ServletHandler:qtp1104106489-15: /test
java.lang.ClassCastException: org.eclipse.jetty.server.Request cannot be cast to org.eclipse.jetty.server.Request
        at httptest.ServerPushServlet.doGet(ServerPushServlet.java:19)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
        at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:821)
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:583)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
        at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524)
        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.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)
        at java.lang.Thread.run(Thread.java:745)

It seems that the "request" object is an instance of org.eclipse.jetty.server.Request. But why ClassCastException is thrown?
In fact, the exception message also indicates the type of "request" is org.eclipse.jetty.server.Request.

The following jar files are in my war (and only this war in my base),
jetty-http-9.3.5.v20151012.jar
jetty-server-9.3.5.v20151012.jar
jetty-servlets-9.3.5.v20151012.jar
jetty-util-9.3.5.v20151012.jar

How to resolve this problem?

Thanks!

Sha

Back to the top