org.eclipse.jetty.server.Request cannot be cast to org.eclipse.jetty.server.Request

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

org.eclipse.jetty.server.Request cannot be cast to org.eclipse.jetty.server.Request

John Jiang
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
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: org.eclipse.jetty.server.Request cannot be cast to org.eclipse.jetty.server.Request

Dimitar Georgiev

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" <[hidden email]> 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
[hidden email]
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
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: org.eclipse.jetty.server.Request cannot be cast to org.eclipse.jetty.server.Request

John Jiang
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 <[hidden email]>:

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" <[hidden email]> 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
[hidden email]
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
[hidden email]
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
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: org.eclipse.jetty.server.Request cannot be cast to org.eclipse.jetty.server.Request

John Jiang
Additionally, I run command "java -jar ../start.jar --list-config" for my base. The below is a part of the output,

Jetty Server Classpath:
-----------------------
Version Information on 37 entries in the classpath.
Note: order presented here is how they would appear on the classpath.
      changes to the --module=name command line options will be reflected here.
 0:          9.3.5.v20151012 | ${jetty.home}\lib\jetty-client-9.3.5.v20151012.jar
 1:          9.3.5.v20151012 | ${jetty.home}\lib\jetty-continuation-9.3.5.v20151012.jar
 2:                    (dir) | ${jetty.base}\resources
 3:                    3.1.0 | ${jetty.home}\lib\servlet-api-3.1.jar
 4:                 3.1.0.M0 | ${jetty.home}\lib\jetty-schemas-3.1.jar
 5:          9.3.5.v20151012 | ${jetty.home}\lib\jetty-http-9.3.5.v20151012.jar
 6:          9.3.5.v20151012 | ${jetty.home}\lib\jetty-server-9.3.5.v20151012.jar
 7:          9.3.5.v20151012 | ${jetty.home}\lib\jetty-xml-9.3.5.v20151012.jar
 8:          9.3.5.v20151012 | ${jetty.home}\lib\jetty-util-9.3.5.v20151012.jar
 9:          9.3.5.v20151012 | ${jetty.home}\lib\jetty-io-9.3.5.v20151012.jar
10:          9.3.5.v20151012 | ${jetty.home}\lib\jetty-jndi-9.3.5.v20151012.jar
11:      1.4.1.v201005082020 | ${jetty.home}\lib\jndi\javax.mail.glassfish-1.4.1.v201005082020.jar
12:                      1.2 | ${jetty.home}\lib\jndi\javax.transaction-api-1.2.jar
13:          9.3.5.v20151012 | ${jetty.home}\lib\jetty-security-9.3.5.v20151012.jar
14:          9.3.5.v20151012 | ${jetty.home}\lib\jetty-servlet-9.3.5.v20151012.jar
15:          9.3.5.v20151012 | ${jetty.home}\lib\jetty-alpn-client-9.3.5.v20151012.jar
16:          9.3.5.v20151012 | ${jetty.home}\lib\jetty-alpn-server-9.3.5.v20151012.jar
17:          9.3.5.v20151012 | ${jetty.home}\lib\http2\http2-client-9.3.5.v20151012.jar
18:          9.3.5.v20151012 | ${jetty.home}\lib\http2\http2-common-9.3.5.v20151012.jar
19:          9.3.5.v20151012 | ${jetty.home}\lib\http2\http2-hpack-9.3.5.v20151012.jar
20:          9.3.5.v20151012 | ${jetty.home}\lib\http2\http2-server-9.3.5.v20151012.jar
21:          9.3.5.v20151012 | ${jetty.home}\lib\jetty-servlets-9.3.5.v20151012.jar
22:          9.3.5.v20151012 | ${jetty.home}\lib\jetty-webapp-9.3.5.v20151012.jar
23:          9.3.5.v20151012 | ${jetty.home}\lib\jetty-deploy-9.3.5.v20151012.jar
24:          9.3.5.v20151012 | ${jetty.home}\lib\jetty-plus-9.3.5.v20151012.jar
25:          9.3.5.v20151012 | ${jetty.home}\lib\jetty-annotations-9.3.5.v20151012.jar
26:                    5.0.1 | ${jetty.home}\lib\annotations\asm-5.0.1.jar
27:                    5.0.1 | ${jetty.home}\lib\annotations\asm-commons-5.0.1.jar
28:                      1.2 | ${jetty.home}\lib\annotations\javax.annotation-api-1.2.jar
29:                      1.0 | ${jetty.home}\lib\websocket\javax.websocket-api-1.0.jar
30:          9.3.5.v20151012 | ${jetty.home}\lib\websocket\javax-websocket-client-impl-9.3.5.v20151012.jar
31:          9.3.5.v20151012 | ${jetty.home}\lib\websocket\javax-websocket-server-impl-9.3.5.v20151012.jar
32:          9.3.5.v20151012 | ${jetty.home}\lib\websocket\websocket-api-9.3.5.v20151012.jar
33:          9.3.5.v20151012 | ${jetty.home}\lib\websocket\websocket-client-9.3.5.v20151012.jar
34:          9.3.5.v20151012 | ${jetty.home}\lib\websocket\websocket-common-9.3.5.v20151012.jar
35:          9.3.5.v20151012 | ${jetty.home}\lib\websocket\websocket-server-9.3.5.v20151012.jar
36:          9.3.5.v20151012 | ${jetty.home}\lib\websocket\websocket-servlet-9.3.5.v20151012.jar

What is missing?

2015-12-31 10:15 GMT+08:00 John Jiang <[hidden email]>:
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 <[hidden email]>:

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" <[hidden email]> 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
[hidden email]
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
[hidden email]
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
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: org.eclipse.jetty.server.Request cannot be cast to org.eclipse.jetty.server.Request

Simone Bordet-3
In reply to this post by John Jiang
Hi,

On Wed, Dec 30, 2015 at 1:03 PM, John Jiang <[hidden email]> 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)

The Servlet specification mandates that server implementation classes
must be hidden from webapps.
As such, you cannot use server classes in your webapp.

If you try to include the jetty-server-<version>.jar in your war, you
get the ClassCastException.
If you remove it from the war, you get a ClassNotFoundException
because the server hides it from the webapp.

If you really need to use Jetty's classes, your best bet is to avoid
webapps and their classloading, and just use Jetty's
ServletContextHandler which will allow you to deploy Servlets without
the classloading complications.

--
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support
from the Jetty & CometD experts.
_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: org.eclipse.jetty.server.Request cannot be cast to org.eclipse.jetty.server.Request

John Jiang
Hi Simone,
Thanks for your help!

BTW, why org.eclipse.jetty.servlets.PushCacheFilter can use org.eclipse.jetty.server.Request directly?

2015-12-31 18:32 GMT+08:00 Simone Bordet <[hidden email]>:
Hi,

On Wed, Dec 30, 2015 at 1:03 PM, John Jiang <[hidden email]> 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)

The Servlet specification mandates that server implementation classes
must be hidden from webapps.
As such, you cannot use server classes in your webapp.

If you try to include the jetty-server-<version>.jar in your war, you
get the ClassCastException.
If you remove it from the war, you get a ClassNotFoundException
because the server hides it from the webapp.

If you really need to use Jetty's classes, your best bet is to avoid
webapps and their classloading, and just use Jetty's
ServletContextHandler which will allow you to deploy Servlets without
the classloading complications.

--
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support
from the Jetty & CometD experts.
_______________________________________________
jetty-users mailing list
[hidden email]
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
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: org.eclipse.jetty.server.Request cannot be cast to org.eclipse.jetty.server.Request

Simone Bordet-3
Hi,

On Fri, Jan 1, 2016 at 12:56 AM, John Jiang <[hidden email]> wrote:
> Hi Simone,
> Thanks for your help!
>
> BTW, why org.eclipse.jetty.servlets.PushCacheFilter can use
> org.eclipse.jetty.server.Request directly?

Because it's a special case for which we punched a hole in the
classloading mechanism, ensuring that is always loaded from the server
classpath (and not from webapp's).

--
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support
from the Jetty & CometD experts.
_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: org.eclipse.jetty.server.Request cannot be cast to org.eclipse.jetty.server.Request

John Jiang
Got it, thanks!

2016-01-02 1:55 GMT+08:00 Simone Bordet <[hidden email]>:
Hi,

On Fri, Jan 1, 2016 at 12:56 AM, John Jiang <[hidden email]> wrote:
> Hi Simone,
> Thanks for your help!
>
> BTW, why org.eclipse.jetty.servlets.PushCacheFilter can use
> org.eclipse.jetty.server.Request directly?

Because it's a special case for which we punched a hole in the
classloading mechanism, ensuring that is always loaded from the server
classpath (and not from webapp's).

--
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support
from the Jetty & CometD experts.
_______________________________________________
jetty-users mailing list
[hidden email]
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
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users