Skip to main content

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

Thanks for the reply.

In fact, I had tried to exclude jetty-server-9.3.5.v20151012.jar, which includes class org.eclipse.jetty.server.Request.
My base contains a start.ini, and it includes configuration --module=server.
For this case, I met error: java.lang.NoClassDefFoundError: org/eclipse/jetty/server/Request

2015-12-30 20:12 GMT+08:00 Dimitar Georgiev <dimitar.georgiev.bg@xxxxxxxxx>:

Those things should be provided by jetty and not packaged in the war. The classcast means different classloaders. Just exclude them from the jar. If using maven - use provided scope?

On 30 Dec 2015 14:04, "John Jiang" <john.sha.jiang@xxxxxxxxx> wrote:
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

_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users

_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users


Back to the top