Atmosphere/atmosphere-extensions — pull request #146 by tfukushima (2014-05-15 16:18:53+00:00)
Title: Modify AtmosphereGuiceServlet not to use Atmosphere's GuiceContainer

This patch deletes GuiceContainer and switches AtmosphereGuiceServlet to
use Jersey's GuiceContainer instead.

This fixes #144.

Signed-off-by: Taku Fukushima

--------------------------------------------

## Please do not merge this. Unit tests are failing.

Sorry for that but it's late here in Japan and I'll fix this tomorrow. And actually I'm not sure this is the right way to fix the issue.

```
setUpGlobal(org.atmosphere.tests.guice.jersey.JettyGuiceJerseyTest) Time elapsed: 0.613 sec <<< FAILURE!
MultiException[javax.servlet.ServletException: com.google.inject.ConfigurationException: Guice configuration errors:
1) Could not find a suitable constructor in com.sun.jersey.guice.spi.container.servlet.GuiceContainer. Classes must have either one (and only one) constructor
annotated with @Inject or a zero-argument constructor that is not private.
at com.sun.jersey.guice.spi.container.servlet.GuiceContainer.class(GuiceContainer.java:108)
while locating com.sun.jersey.guice.spi.container.servlet.GuiceContainer
1 error, java.lang.IllegalStateException: !Selecting]
at org.eclipse.jetty.server.Server.doStart(Server.java:254)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
at org.atmosphere.tests.guice.jersey.JettyGuiceJerseyTest.startServer(JettyGuiceJerseyTest.java:146)
at org.atmosphere.tests.guice.jersey.JettyGuiceJerseyTest.setUpGlobal(JettyGuiceJerseyTest.java:106)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:580)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:398)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:145)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:427)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:617)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:885)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:126)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:110)
at org.testng.TestRunner.runWorkers(TestRunner.java:712)
at org.testng.TestRunner.privateRun(TestRunner.java:582)
at org.testng.TestRunner.run(TestRunner.java:477)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:324)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:319)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:292)
at org.testng.SuiteRunner.run(SuiteRunner.java:198)
at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:821)
at org.testng.TestNG.runSuitesLocally(TestNG.java:788)
at org.testng.TestNG.run(TestNG.java:708)
at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:77)
at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.executeMulti(TestNGDirectoryTestSuite.java:159)
at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:99)
at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:106)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
javax.servlet.ServletException: com.google.inject.ConfigurationException: Guice configuration errors:
1) Could not find a suitable constructor in com.sun.jersey.guice.spi.container.servlet.GuiceContainer. Classes must have either one (and only one) constructor
annotated with @Inject or a zero-argument constructor that is not private.
at com.sun.jersey.guice.spi.container.servlet.GuiceContainer.class(GuiceContainer.java:108)
while locating com.sun.jersey.guice.spi.container.servlet.GuiceContainer
1 error
at org.atmosphere.cpr.AtmosphereFramework.loadConfiguration(AtmosphereFramework.java:1361)
at org.atmosphere.cpr.AtmosphereFramework.init(AtmosphereFramework.java:865)
at org.atmosphere.cpr.AtmosphereFramework.init(AtmosphereFramework.java:763)
at org.atmosphere.cpr.AtmosphereServlet.configureFramework(AtmosphereServlet.java:100)
at org.atmosphere.cpr.AtmosphereServlet.init(AtmosphereServlet.java:80)
at com.google.inject.servlet.ServletDefinition.init(ServletDefinition.java:83)
at com.google.inject.servlet.ManagedServletPipeline.init(ManagedServletPipeline.java:84)
at com.google.inject.servlet.ManagedFilterPipeline.initPipeline(ManagedFilterPipeline.java:106)
at com.google.inject.servlet.GuiceFilter.init(GuiceFilter.java:168)
at org.eclipse.jetty.servlet.FilterHolder.doStart(FilterHolder.java:102)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:747)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:249)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:676)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:90)
at org.eclipse.jetty.server.Server.doStart(Server.java:261)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
at org.atmosphere.tests.guice.jersey.JettyGuiceJerseyTest.startServer(JettyGuiceJerseyTest.java:146)
at org.atmosphere.tests.guice.jersey.JettyGuiceJerseyTest.setUpGlobal(JettyGuiceJerseyTest.java:106)
Caused by: com.google.inject.ConfigurationException: Guice configuration errors:
1) Could not find a suitable constructor in com.sun.jersey.guice.spi.container.servlet.GuiceContainer. Classes must have either one (and only one) constructor
annotated with @Inject or a zero-argument constructor that is not private.
at com.sun.jersey.guice.spi.container.servlet.GuiceContainer.class(GuiceContainer.java:108)
while locating com.sun.jersey.guice.spi.container.servlet.GuiceContainer
1 error
at com.google.inject.InjectorImpl.getProvider(InjectorImpl.java:784)
at com.google.inject.InjectorImpl.getProvider(InjectorImpl.java:743)
at com.google.inject.InjectorImpl.getInstance(InjectorImpl.java:793)
at org.atmosphere.guice.AtmosphereGuiceServlet$1.configureDetectedFramework(AtmosphereGuiceServlet.java:49)
at org.atmosphere.cpr.AtmosphereFramework.detectSupportedFramework(AtmosphereFramework.java:1407)
at org.atmosphere.cpr.AtmosphereFramework.loadConfiguration(AtmosphereFramework.java:1355)
... 54 more
java.lang.IllegalStateException: !Selecting
at org.eclipse.jetty.io.nio.SelectorManager.doStart(SelectorManager.java:309)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
at org.eclipse.jetty.util.component.AggregateLifeCycle.doStart(AggregateLifeCycle.java:58)
at org.eclipse.jetty.server.AbstractConnector.doStart(AbstractConnector.java:319)
at org.eclipse.jetty.server.nio.SelectChannelConnector.doStart(SelectChannelConnector.java:251)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
at org.eclipse.jetty.server.Server.doStart(Server.java:272)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59)
at org.atmosphere.tests.guice.jersey.JettyGuiceJerseyTest.startServer(JettyGuiceJerseyTest.java:146)
at org.atmosphere.tests.guice.jersey.JettyGuiceJerseyTest.setUpGlobal(JettyGuiceJerseyTest.java:106)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:580)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:398)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:145)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:427)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:617)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:885)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:126)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:110)
at org.testng.TestRunner.runWorkers(TestRunner.java:712)
at org.testng.TestRunner.privateRun(TestRunner.java:582)
at org.testng.TestRunner.run(TestRunner.java:477)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:324)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:319)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:292)
at org.testng.SuiteRunner.run(SuiteRunner.java:198)
at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:821)
at org.testng.TestNG.runSuitesLocally(TestNG.java:788)
at org.testng.TestNG.run(TestNG.java:708)
at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:77)
at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.executeMulti(TestNGDirectoryTestSuite.java:159)
at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:99)
at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:106)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)

Results :

Failed tests: setUpGlobal(org.atmosphere.tests.guice.jersey.JettyGuiceJerseyTest): Multiple exceptions

Tests run: 3, Failures: 1, Errors: 0, Skipped: 1
```