domingo, 14 de julho de 2013

Fixing Run-Jetty-Run Eclipse Plugin to Run Websockets

Run-Jetty-Run is an Eclipse plugin for running and debugging web apps using Jetty container. Although it has been a great and useful tool in the past days, lately, when I was playing around with websockets, I’ve found it was not working properly as it should.

It is important to say that the current stable build of Run-Jetty-Run plugin does not support the latest Jetty version (i.e. 9.0.4), so it became necessary to get its nightly build. Once I downloaded it, I've noticed it was not up-to-date either. Actually the last nightly build is pretty old too (the build date is 01/02/2013) and, unfortunately, it only supports Jetty 9.0.0.M3.

So, If you are facing the below issue or if you are a curious person, I would suggest you to keep reading.

java.util.ServiceConfigurationError: org.eclipse.jetty.websocket.servlet.WebSocketServletFactory: Provider org.eclipse.jetty.websocket.server.WebSocketServerFactory not found
at java.util.ServiceLoader.access$300(
at java.util.ServiceLoader$
at java.util.ServiceLoader$
at org.eclipse.jetty.websocket.servlet.WebSocketServlet.init(
at javax.servlet.GenericServlet.init(
at org.eclipse.jetty.servlet.ServletHolder.initServlet(
at org.eclipse.jetty.servlet.ServletHolder.getServlet(
at org.eclipse.jetty.servlet.ServletHolder.handle(
at org.eclipse.jetty.servlet.ServletHandler.doHandle(
at org.eclipse.jetty.server.handler.ScopedHandler.handle(
at org.eclipse.jetty.server.session.SessionHandler.doHandle(
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(
at org.eclipse.jetty.servlet.ServletHandler.doScope(
at org.eclipse.jetty.server.session.SessionHandler.doScope(
at org.eclipse.jetty.server.handler.ContextHandler.doScope(
at org.eclipse.jetty.server.handler.ScopedHandler.handle(
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(
at org.eclipse.jetty.server.Server.handle(
at org.eclipse.jetty.server.HttpConnection$
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(
at org.eclipse.jetty.util.thread.QueuedThreadPool$

Once the Run-Jetty-Run team seems to not be working anymore and since there were some changes in the internal Jetty API, I’ve decided to fix it by myself and to post the result to make life simple for everyone trying to run websockets into Eclipse.

It is important to say that this fix was tested only in the Eclipse Kepler. So, in order to avoid other issues, ensure you have the latest version of Kepler IDE. After that, you can follow the following steps:

  1. First of all, you must install the core of the Run-Jetty-Run plugin.
    1. For that, go to Help -> Install New Software.
    2. Then, enter the URL and install the Run Jetty Run Feature (Required)
  2. Once the core plugin has being installed, you must install my customized support for running Jetty 9.0.4.
    1. Copy the downloaded jar into the /<YOU_ECLIPSE_KEPLER_HOME>/plugins
    2. And, restart the eclipse
  3. Finally, right click on your websocket app and choose RunAs -> Run Jetty
    1. In Jetty tab, select the following Jetty Version: Jetty
    2. In Jetty Classpath tab, add your project in the Custom Jetty Classpath
      1. It is important to say that this step is only necessary because there is another bug in the core plugin which I didn’t want to lose my time to fix.
    3. So, we are done!!
      1. Click in the Run button and have fun..

Hope I’ve helped to make your life simple. ;-)

Thanks for reading.

Nenhum comentário:

Postar um comentário