Theres something wrong, worked fine with no guice bindings, but as soon as I
got one I get this:
Starting grizzly...
2010-03-05 09:27:08
com.sun.jersey.server.impl.application.WebApplicationImpl initiate
INFO: Initiating Jersey application, version 'Jersey: 1.1.4.1 11/24/2009
01:30 AM'
2010-03-05 09:27:08
com.sun.jersey.server.impl.application.WebApplicationImpl
processRootResources
SEVERE: The ResourceConfig instance does not contain any root resource
classes.
2010-03-05 09:27:08 com.sun.grizzly.http.servlet.ServletAdapter service
SEVERE: service exception:
com.sun.jersey.api.container.ContainerException: The ResourceConfig instance
does not contain any root resource classes.
at
com.sun.jersey.server.impl.application.WebApplicationImpl.processRootResources(WebApplicationImpl.java:849)
at
com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:718)
at
com.sun.jersey.guice.spi.container.servlet.GuiceContainer.initiate(GuiceContainer.java:112)
at
com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.initiate(ServletContainer.java:253)
at
com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:521)
at
com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:199)
at
com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:308)
at
com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:471)
at javax.servlet.GenericServlet.init(GenericServlet.java:241)
at
com.sun.grizzly.http.servlet.ServletAdapter.loadServlet(ServletAdapter.java:327)
at
com.sun.grizzly.http.servlet.ServletAdapter.service(ServletAdapter.java:268)
at
com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:165)
at
com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:659)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:577)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:829)
at
com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:162)
at
com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:136)
at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:103)
at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:89)
at
com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
at
com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:67)
at
com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:269)
at java.util.concurrent.FutureTask.run(FutureTask.java:123)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
at java.lang.Thread.run(Thread.java:595)
And the code:
protected static SelectorThread startServer() throws IOException {
final Map<String, String> initParams = new HashMap<String,
String>();
initParams.put("com.sun.jersey.config.property.packages",
"com.netdesign.rest");
System.out.println("Starting grizzly...");
ServletAdapter adapter = new ServletAdapter();
Injector injector = Guice.createInjector(new MyModule());
GuiceContainer container = new GuiceContainer(injector);
adapter.setServletInstance(container);
GuiceFilter filter = new GuiceFilter();
adapter.addFilter(filter, "guiceFilter", null);
SelectorThread threadSelector = GrizzlyServerFactory.create(
BASE_URI, adapter);
return threadSelector;
}
public static void main(String[] args) throws IOException {
SelectorThread threadSelector = startServer();
System.out.println(String.format(
"Jersey app started with WADL available at "
+ "%sapplication.wadl\nHit enter to stop it...",
BASE_URI));
System.in.read();
threadSelector.stopEndpoint();
}
2010/3/5 nino martinez wael <[email protected]>
> Hi Eelco
>
> Thanks for the response :)
>
> Distilling it, it becomes something like this:
>
> ServletAdapter adapter = new ServletAdapter();
> Injector injector =Guice.createInjector(MyModule);
> GuiceContainer container=new GuiceContainer(injector);
>
> adapter.setServletInstance(container);
> GuiceFilter filter = new GuiceFilter();
> adapter.addFilter(filter, "guiceFilter", null);
>
> SelectorThread threadSelector = GrizzlyServerFactory.create(
> "http://localhost:9998/", adapter);
>
> Right?
>
> \/\/
> -Nino
>
> 2010/3/4 Eelco Hillenius <[email protected]>
>
> > I'm using a tweaked version of contribs/jersey-guice, part of the
>> > jersey project. See
>> >
>> https://jersey.dev.java.net/nonav/apidocs/1.1.5/contribs/jersey-guice/index.html
>>
>> Here is the an example of code that I use to setup JAXRS/ Jersey with
>> Guice, but you have to read through the fluff a bit since we built a
>> mini framework around Guice.
>>
>> Settings settings = new Settings();
>>
>> settings.setSetting("com.sun.jersey.config.property.packages",
>>
>> ErrorTrapTest.class.getPackage().getName());
>>
>> Dependencies dependencies = new Dependencies(settings,
>> new ServletModule(), new
>> LocalServiceRegistryModule(),
>> testModule, new SchedulerModule(settings),
>> new ErrorTrapModule());
>>
>> ServletAdapter adapter = new ServletAdapter();
>> JerseyGuiceContainer container = dependencies
>> .getInstance(JerseyGuiceContainer.class);
>> adapter.setServletInstance(container);
>> GuiceFilter filter = new GuiceFilter();
>> adapter.addFilter(filter, "guiceFilter", null);
>>
>> SelectorThread threadSelector =
>> GrizzlyServerFactory.create(
>> "http://localhost:9998/", adapter);
>>
>>
>> In the code above, Settings is a boosted properties loader and
>> Dependencies a wrapper around Injector (which is created in the
>> constructor) that amongst other things binds settings to Names
>> (Names.bindProperties(binder(), settings.getProperties());).
>> JerseyGuiceContainer is a slightly tweaked version of GuiceContainer
>> (
>> https://jersey.dev.java.net/nonav/apidocs/1.1.5/contribs/jersey-guice/com/sun/jersey/guice/spi/container/servlet/GuiceContainer.html
>> ).
>>
>> Hope that helps,
>>
>> Eelco
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "google-guice" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected]<google-guice%[email protected]>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/google-guice?hl=en.
>>
>>
>
--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-guice?hl=en.