Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[guice, websockets] The ResourceConfig instance does not contain any root resource classes #189

Closed
yurique opened this issue Feb 18, 2012 · 3 comments

Comments

@yurique
Copy link

yurique commented Feb 18, 2012

Hi!

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

<listener>
    <listener-class>com.test.GuiceServletConfig</listener-class>
</listener>
<filter>
    <filter-name>guiceFilter</filter-name>
    <filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>guiceFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

and in the following in the com.test.GuiceServletConfig:

public class GuiceServletConfig extends GuiceServletContextListener {

@Override
protected Injector getInjector() {
    return Guice.createInjector(new ServletModule() {
        @Override
        protected void configureServlets() {
            Map<String, String> params = new HashMap<String, String>();
            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<Map<String, String>>() {
            }).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.<init>(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 <servlet-class>org.atmosphere.cpr.AtmosphereServlet</servlet-class>
and <init-param>'s atmosphere starts normally.

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

@jfarcand
Copy link
Member

jfarcand commented Mar 1, 2012

Salut, again, apology for the delay I've completely missed those two issues :-( Either you bind the resource or you pass the Jersey init-param

   com.sun.jersey.config.property.packages

value: your package to make it working. I don't think without Jersey is able to locate its resource. I'm closing the issue as not a bug, please re-open if you think I am wrong.

Thanks!

-- Jeanfrancois

@jfarcand jfarcand closed this as completed Mar 1, 2012
@yurique
Copy link
Author

yurique commented Mar 7, 2012

Hi! Thanks for clarifying this!

@issamm
Copy link

issamm commented Feb 11, 2013

Hi. I'm having the same problem with Atmosphere 1.1.0.beta2, on Jetty 8.1.2.v20120308.

The difference is that I'm not using Guice (and don't know what it is)
The exception :

2013-02-11 10:40:06.241:WARN:oejs.ServletHandler:/myws com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes.

I use this Eclipse plugin : run-jetty-run
In my web.xml :

<servlet>
        <description>AtmosphereServlet</description>
        <servlet-name>AtmosphereServlet</servlet-name>
        <servlet-class>org.atmosphere.cpr.AtmosphereServlet</servlet-class>
        <init-param>
            <param-name>com.sun.jersey.config.property.packages</param-name>
            <param-value>my.package</param-value>
        </init-param>
</servlet>

with "my.package" containing my WebSocketHandlerAdapter implementation.

Do you have an idea please ?

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants