Atmosphere/atmosphere — Issue #189: [guice, websocket] The ResourceConfig instance does not contain any root resource classes
Author: yurique
Created: 2012-02-18 02:09:56+00:00
State: open

Hi!

I've faced this problem trying to run a guice/websocket application in Jetty.
In web.xml I have something like this:

com.test.GuiceServletConfig

guiceFilter
com.google.inject.servlet.GuiceFilter

guiceFilter
/*

and in com.test.GuiceServletConfig:
public class GuiceServletConfig extends GuiceServletContextListener {

@Override
protected Injector getInjector() {
return Guice.createInjector(new ServletModule() {
@Override
protected void configureServlets() {
Map params = new HashMap();
params.put("org.atmosphere.useWebSocket", "true");
params.put("org.atmosphere.useNative", "true");
params.put("org.atmosphere.websocket.WebSocketProtocol",
"com.test.TestWebSocketProtocol"); // which extends WebSocketProtocol
bind(new TypeLiteral>() {
}).annotatedWith(
Names.named("org.atmosphere.guice.AtmosphereGuiceServlet.properties")
).toInstance(params);
serve("/ws/*").with(GuiceManagedAtmosphereServlet.class, params);
}
});
}
}

And during deployment I get this exception thrown:

03:25:53.372 [Scanner-1] ERROR org.atmosphere.cpr.AtmosphereServlet - failed to initialize atmosphere framework
com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes.
at com.sun.jersey.server.impl.application.RootResourceUriRules.(RootResourceUriRules.java:99) ~[jersey-server-1.9.1.jar:1.9.1]
at com.sun.jersey.server.impl.application.WebApplicationImpl._initiate(WebApplicationImpl.java:1298) ~[jersey-server-1.9.1.jar:1.9.1]
at com.sun.jersey.server.impl.application.WebApplicationImpl.access$700(WebApplicationImpl.java:169) ~[jersey-server-1.9.1.jar:1.9.1]
at com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApplicationImpl.java:775) ~[jersey-server-1.9.1.jar:1.9.1]
at com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApplicationImpl.java:771) ~[jersey-server-1.9.1.jar:1.9.1]
at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:193) ~[jersey-core-1.9.1.jar:1.9.1]
at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:779) ~[jersey-server-1.9.1.jar:1.9.1]
at org.atmosphere.guice.GuiceContainer.initiate(GuiceContainer.java:82) ~[atmosphere-guice-0.8.5.jar:0.8.5]
...

If I configure the same application via web.xml with `org.atmosphere.cpr.AtmosphereServlet`
and ``'s atmosphere starts normally.

If I add a following line: `bind(ResourceChat.class);` (from chat example) it starts normally.