I\'m trying to write a test case which creates a socket and connects to an embedded jetty instance. I\'m using
Don't mix versions of Jetty.
This is an unfortunate side effect of the design of the JSR-356 API. (The Client implementation is the root implementation, and the Server implementation is built on top of that)
The Client container is initialized per JVM, and each server container is initialized per webapp.
Your stacktrace is not Jetty 9.2.0.RC0 as you indicated (the line numbers are off)
https://github.com/eclipse/jetty.project/blob/jetty-9.2.0.RC0/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/ConnectionManager.java#L200
They seem to be from Jetty 9.1.5.v20140505
https://github.com/eclipse/jetty.project/blob/jetty-9.1.5.v20140505/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/ConnectionManager.java#L200
Use Jetty 9.2.2.v20140723 everywhere.
Also, using this version means you can get rid of the finally container.stop() hack.