Switching to Jetty

155 views
Skip to first unread message

Matthew Tyson

unread,
Jan 11, 2012, 9:13:38 PM1/11/12
to cometd-users
So I'm switching our comet support over from Tomcat to Jetty, given all the Tomcat issues we've had with nio/comet.

I've got things working fine by deploying inside a jetty app, but for various reasons, we want to use Jetty as an embedded server.

I'm seeing the following error:

java.lang.AbstractMethodError: org.mortbay.jetty.servlet.ServletHttpRequest.startAsync()Ljavax/servlet/AsyncContext;
at org.eclipse.jetty.continuation.Servlet3Continuation.suspend(Servlet3Continuation.java:171)
        at org.cometd.server.transport.LongPollingTransport.handle(LongPollingTransport.java:281)
        at org.cometd.server.CometdServlet.service(CometdServlet.java:173)
...und so weiter...

And I thought, I need to set async true on my cometd servlet - how can I do that?

And then I thought - how do I tell this thing we are in servlet 3.0?

Is there a good resource to answer these questions, or do you think I'm better off defining stuff in a web.xml and using that?

Here is the servlet code:

ServletHolder cometdServlet = context.addServlet("CometdServlet", "/cometd/*", "org.cometd.server.CometdServlet");
cometdServlet.setInitParameter("async-supported", "true");  // this isn't correct

Thanks,

Matt

Matthew Tyson

unread,
Jan 11, 2012, 9:38:41 PM1/11/12
to cometd-users
I should mention I am using jetty 7.4.4, and it looks like I've got 

org.mortbay.jetty.servlet.ServletHolder

With no setAsyncSupported() method as seen in the Eclipse version here http://download.eclipse.org/jetty/stable-7/apidocs/org/eclipse/jetty/servlet/ServletHolder.html.

Matthew Tyson

unread,
Jan 11, 2012, 9:44:40 PM1/11/12
to cometd-users
Ok, I see that this jetty.jar must be jetty 6.  I need to sort out our dependencies.

I'd still appreciate any input on embedded Jetty + cometd.

Simone Bordet

unread,
Jan 12, 2012, 3:38:00 AM1/12/12
to cometd...@googlegroups.com
Hi,

the Jetty versions that implement the Servlet 3 spec are 8.x and greater.
Jetty 7.x still implements 2.5, and that's why you have those missing
method errors.

However, you do not need Servlet 3 to use CometD in Jetty, unless your
application make direct use of Servlet 3 features.

So, the recommended setup would be CometD 2.3.1 + Jetty 7.4.5, and
make sure you have the right servlet jar in the classpath (must be the
servlet 2.5 jar).
Jetty autodetects the Servlet specification version by loading the
Servlet class and testing if new Servlet 3 methods are present, you
must be careful about what servlet jar you have in classpath.
With the right jar, you should be good.

For an example of how to setup CometD using Jetty embedded, look here:
https://github.com/cometd/cometd/blob/master/cometd-java/cometd-java-examples/src/main/java/org/cometd/examples/CometdDemo.java
https://github.com/cometd/cometd/blob/master/cometd-javascript/common-test/src/test/java/org/cometd/javascript/AbstractCometDTest.java

Simon
--
http://cometd.org
http://intalio.com
http://bordet.blogspot.com
----
Finally, no matter how good the architecture and design are,
to deliver bug-free software with optimal performance and reliability,
the implementation technique must be flawless.   Victoria Livschitz

Matthew Tyson

unread,
Jan 12, 2012, 1:06:14 PM1/12/12
to cometd...@googlegroups.com
--
You received this message because you are subscribed to the Google Groups "cometd-users" group.
To post to this group, send email to cometd...@googlegroups.com
To unsubscribe from this group, send email to cometd-users...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cometd-users

Visit the CometD website at http://www.cometd.org

Thanks Simone, always appreciate your help.  And thanks for the great project.
Reply all
Reply to author
Forward
0 new messages