Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Jetty and WebSockets

I figured this out, I added external dependencies provided in the jetty and added to the manifest of my server the web socket jars, now the servlet starts ok the jars are called ok and there are no duplicates, with a test page I can see connection ok and messages go through and have replies.

need to know now how to make different endpoints, now everything is connected to the EchoTest I will check the annotations.

for the client for example if I use javafx apart from the jar marked as client, which others are necessary?

thanks



On August 20, 2013 at 4:52:18 PM, Sebastian Gutierrez (scgm11@xxxxxxxxx) wrote:

I think I have an idea why this may be… 
can I contact you directly via Skype so I can show you?

JDK 1.7up 21
OS Ubuntu 12.04

the Manifest is to indicate my jar file, where are the jetty libraries located.

All these may be because how my environment is setted up.


As I told you I have a jar file that has the configuration of jetty by code, and the libs are the basic jetty libraries needed to run.
then the war file that has all the REST things has a web.xml that has the servlets parts, now with the Socket I had to add all the libraries of jetty that were needed not only the ones about web sockets.. so here is where I think that the instance is different so the null pointer, but I think is easier to show you directly sharing my screen and showing you the projects.

I have no idea if this could be achievable. I suppose that if I use other implementation on web socket directly could work… but I would like to stick to jetty.

thanks






On August 20, 2013 at 4:29:16 PM, Joakim Erdfelt (joakim@xxxxxxxxxxx) wrote:

Odd, very odd.

You are definately using websocket correctly, and your servlet is being hit.
However, these 2 lines are causing a NPE for you.


Now why is HttpConnection.getCurrentConnection() null for you?

The HttpConnection:229 is present on your stacktrace.
And a few lines above that handle method is the setting of your current connection.

That is a very strange bug you are experiencing.
What JDK are you using? And on what OS?
I'd like to attempt to replicate.


--
Joakim Erdfelt <joakim@xxxxxxxxxxx>
Expert advice, services and support from from the Jetty & CometD experts


On Tue, Aug 20, 2013 at 12:04 PM, Sebastian Gutierrez <scgm11@xxxxxxxxx> wrote:
I've move a bit forward:

9.0.5



this is the exception...


 2013-08-16 20:42:35.458:WARN:oejs.ServletHandler:qtp1118598848-18: /Integra/websockets/
java.lang.NullPointerException
        at org.eclipse.jetty.websocket.server.WebSocketServerFactory.upgrade(WebSocketServerFactory.java:415)
        at org.eclipse.jetty.websocket.server.WebSocketServerFactory.acceptWebSocket(WebSocketServerFactory.java:178)
        at org.eclipse.jetty.websocket.servlet.WebSocketServlet.service(WebSocketServlet.java:160)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
        at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:698)
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:505)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:138)
        at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:564)
        at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:213)
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1096)
        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:432)
        at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:175)
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1030)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:136)
        at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:52)
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
        at org.eclipse.jetty.server.Server.handle(Server.java:445)
        at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:268)
        at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:229)
        at org.eclipse.jetty.io.AbstractConnection$ReadCallback.run(AbstractConnection.java:358)
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:601)
        at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:532)
        at java.lang.Thread.run(Thread.java:722)


maybe this is wrong on my xml:

 <servlet-mapping>
        <servlet-name>servlet</servlet-name>
        <url-pattern>/websockets/*</url-pattern>
    </servlet-mapping>

?

thanks!

On August 20, 2013 at 3:47:34 PM, Sebastian Gutierrez (scgm11@xxxxxxxxx) wrote:

forget about this, is the manifest wrong…




On August 20, 2013 at 3:35:19 PM, Sebastian Gutierrez (scgm11@xxxxxxxxx) wrote:

is there any breaking changes for embedded between 9.0.3 and 9.04 and 9.05 because I'm moving from 3 to 5 and now I have 
this exception

root@server:/etc/IntegraServer/server# Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/jetty/server/HttpConfiguration$Customizer
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Class.java:2451)
        at java.lang.Class.getMethod0(Class.java:2694)
        at java.lang.Class.getMethod(Class.java:1622)
        at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
        at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)
Caused by: java.lang.ClassNotFoundException: org.eclipse.jetty.server.HttpConfiguration$Customizer
        at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
        ... 6 more

although the class seems to be on the jetty server jar……

any idea??

then I will move further on the web socket issue, 9.0.3 doesn't have a web socket client jar..


On August 20, 2013 at 2:52:19 PM, Joakim Erdfelt (joakim@xxxxxxxxxxx) wrote:

Yeah.

And then type in your websocket uri and try it out.


--
Joakim Erdfelt <joakim@xxxxxxxxxxx>
Expert advice, services and support from from the Jetty & CometD experts


On Tue, Aug 20, 2013 at 10:43 AM, Sebastian Gutierrez <scgm11@xxxxxxxxx> wrote:
that's exactly as I have done, but it seems that JettyWebSocketServlet never gets executed, for example if I add some log on the configure override method, that one is never executed. when the server start, maybe it does´t get executed until the first request or something like that?? is there any simple way to test the web socket? lets say pasting the url on a web browser that supports them?? or is there any thin client out there to check it?



any other pointer??

thanks a lot!



On August 20, 2013 at 2:35:52 PM, Joakim Erdfelt (joakim@xxxxxxxxxxx) wrote:

hine.hostname" is your server's host name (or ip)
The "port" is the non-SSL port you have configured your server on.
The "webapp.context" is the context path where you deployed your web application
and "/websockets/" is the request path you have specified in your servlet-mapping




Back to the top