按照此处列出的示例:http://angularjstutorial.blogspot.ca/2013/10/atmosphere-and-angularjs.html#.VeewkNwrJhG
我设法让websocket在jetty上运行。但是,在tomcat 7.0.42上运行完全相同的操作失败了。以下是例外代码段:
17:47:27.173 [localhost-startStop-1] INFO o.atmosphere.cpr.AtmosphereFramework - 已安装的WebSocketProtocol org.atmosphere.websocket.protocol.SimpleHttpProtocol 17:47:27.188 [localhost-startStop-1] WARN o.a.cpr.DefaultAsyncSupportResolver - 无法创建AsyncSupport类:class org.atmosphere.container.JSR356AsyncSupport,错误:{} java.lang.reflect.InvocationTargetException:null at sun.reflect.NativeConstructorAccessorImpl.newInstance0(本机方法) 〜[na:1.7.0_40] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) 〜[na:1.7.0_40] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 〜[na:1.7.0_40] at java.lang.reflect.Constructor.newInstance(Constructor.java:526) 〜[na:1.7.0_40] at org.atmosphere.cpr.DefaultAsyncSupportResolver.newCometSupport(DefaultAsyncSupportResolver.java:234) [atmosphere-runtime-2.4.0-RC4.jar:2.4.0-RC4] at org.atmosphere.cpr.DefaultAsyncSupportResolver.resolveWebSocket(DefaultAsyncSupportResolver.java:297) [atmosphere-runtime-2.4.0-RC4.jar:2.4.0-RC4] at org.atmosphere.cpr.DefaultAsyncSupportResolver.resolve(DefaultAsyncSupportResolver.java:283) [atmosphere-runtime-2.4.0-RC4.jar:2.4.0-RC4] at org.atmosphere.cpr.AtmosphereFramework.autoDetectContainer(AtmosphereFramework.java:2057) [atmosphere-runtime-2.4.0-RC4.jar:2.4.0-RC4] at org.atmosphere.cpr.AtmosphereFramework.init(AtmosphereFramework.java:911) [atmosphere-runtime-2.4.0-RC4.jar:2.4.0-RC4] at org.atmosphere.cpr.AtmosphereFramework.init(AtmosphereFramework.java:835) [atmosphere-runtime-2.4.0-RC4.jar:2.4.0-RC4] at org.atmosphere.cpr.AtmosphereFrameworkInitializer.configureFramework(AtmosphereFrameworkInitializer.java:74) [atmosphere-runtime-2.4.0-RC4.jar:2.4.0-RC4] at org.atmosphere.cpr.AtmosphereServlet.configureFramework(AtmosphereServlet.java:83) [atmosphere-runtime-2.4.0-RC4.jar:2.4.0-RC4] at org.atmosphere.cpr.AtmosphereServlet.configureFramework(AtmosphereServlet.java:79) [atmosphere-runtime-2.4.0-RC4.jar:2.4.0-RC4] at org.atmosphere.cpr.AtmosphereServlet.init(AtmosphereServlet.java:74) [atmosphere-runtime-2.4.0-RC4.jar:2.4.0-RC4] at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1280) [catalina.jar:7.0.42] at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1193) [catalina.jar:7.0.42] at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1088) [catalina.jar:7.0.42] at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5176) [catalina.jar:7.0.42] at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5460) [catalina.jar:7.0.42] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [catalina.jar:7.0.42] at org.apache.catalina.core.ContainerBase $ StartChild.call(ContainerBase.java:1559) [catalina.jar:7.0.42] at org.apache.catalina.core.ContainerBase $ StartChild.call(ContainerBase.java:1549) [catalina.jar:7.0.42] at java.util.concurrent.FutureTask.run(FutureTask.java:262)[na:1.7.0_40] 在 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_40] at java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_40] at java.lang.Thread.run(Thread.java:724)[na:1.7.0_40] 引起:java.lang.IllegalStateException: javax.websocket.server.ServerContainer为null。确保你是 使用1.7+并且您的服务器启用了websocket支持 org.atmosphere.container.JSR356AsyncSupport。(JSR356AsyncSupport.java:53) 〜[atmosphere-runtime-2.4.0-RC4.jar:2.4.0-RC4] at org.atmosphere.container.JSR356AsyncSupport。(JSR356AsyncSupport.java:40) 〜[atmosphere-runtime-2.4.0-RC4.jar:2.4.0-RC4] ... 26个常用帧 省略17:47:27.188 [localhost-startStop-1]警告 o.a.cpr.DefaultAsyncSupportResolver - 找到多个容器, 请说明使用哪一个: org.atmosphere.container.Tomcat7CometSupport, org.atmosphere.container.TomcatCometSupport,直到你做,Atmosphere 将使用:class org.atmosphere.container.Tomcat7CometSupport 17:47:27.204 [localhost-startStop-1] INFO o.atmosphere.cpr.AtmosphereFramework - 安装默认值 AtmosphereInterceptors 17:47:27.204 [localhost-startStop-1] INFO o.atmosphere.cpr.AtmosphereFramework - org.atmosphere.interceptor.CorsInterceptor:CORS拦截器支持
我将jdk从6改为7,再改为8,异常仍然存在。
有谁知道如何解决这个问题?