添加气氛后 运行 项目失败: (AtmosphereFrameworkInitializer.java:52)

Failed to run project after adding atmosphere: (AtmosphereFrameworkInitializer.java:52)

我想在 gwt 2.6.1 项目中添加一些 websocket 功能。 我已遵循所有指示。不幸的是我收到一个错误:

   [WARN] FAILED AtmosphereServlet: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getServletRegistration(Ljava/lang/String;)Ljavax/servlet/ServletRegistration;
java.lang.NoSuchMethodError: javax.servlet.ServletContext.getServletRegistration(Ljava/lang/String;)Ljavax/servlet/ServletRegistration;

堆栈跟踪:

Starting Jetty on port 8888
   [WARN] FAILED AtmosphereServlet: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getServletRegistration(Ljava/lang/String;)Ljavax/servlet/ServletRegistration;
java.lang.NoSuchMethodError: javax.servlet.ServletContext.getServletRegistration(Ljava/lang/String;)Ljavax/servlet/ServletRegistration;
    at org.atmosphere.cpr.AtmosphereFrameworkInitializer.configureFramework(AtmosphereFrameworkInitializer.java:52)
    at org.atmosphere.cpr.AtmosphereServlet.configureFramework(AtmosphereServlet.java:84)
    at org.atmosphere.cpr.AtmosphereServlet.configureFramework(AtmosphereServlet.java:80)
    at org.atmosphere.cpr.AtmosphereServlet.init(AtmosphereServlet.java:75)
    at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:534)
    at org.eclipse.jetty.servlet.ServletHolder.doStart(ServletHolder.java:346)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
    at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:786)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:265)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1242)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:717)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:494)
    at com.google.gwt.dev.shell.jetty.JettyLauncher$WebAppContextWithReload.doStart(JettyLauncher.java:541)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
    at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95)
    at org.eclipse.jetty.server.handler.RequestLogHandler.doStart(RequestLogHandler.java:162)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
    at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95)
    at org.eclipse.jetty.server.Server.doStart(Server.java:282)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
    at com.google.gwt.dev.shell.jetty.JettyLauncher.start(JettyLauncher.java:740)
    at com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:522)
    at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:1104)
    at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:844)
    at com.google.gwt.dev.DevMode.main(DevMode.java:322)
   [WARN] FAILED c.g.g.d.s.j.WebAppContextWithReload{/,file:/C:/Mars/workspace/FenixWAR/src/main/webapp/},C:\Mars\workspace\FenixWAR\src\main\webapp: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getServletRegistration(Ljava/lang/String;)Ljavax/servlet/ServletRegistration;
java.lang.NoSuchMethodError: javax.servlet.ServletContext.getServletRegistration(Ljava/lang/String;)Ljavax/servlet/ServletRegistration;
    at org.atmosphere.cpr.AtmosphereFrameworkInitializer.configureFramework(AtmosphereFrameworkInitializer.java:52)
    at org.atmosphere.cpr.AtmosphereServlet.configureFramework(AtmosphereServlet.java:84)
    at org.atmosphere.cpr.AtmosphereServlet.configureFramework(AtmosphereServlet.java:80)
    at org.atmosphere.cpr.AtmosphereServlet.init(AtmosphereServlet.java:75)
    at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:534)
    at org.eclipse.jetty.servlet.ServletHolder.doStart(ServletHolder.java:346)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
    at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:786)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:265)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1242)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:717)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:494)
    at com.google.gwt.dev.shell.jetty.JettyLauncher$WebAppContextWithReload.doStart(JettyLauncher.java:541)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
    at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95)
    at org.eclipse.jetty.server.handler.RequestLogHandler.doStart(RequestLogHandler.java:162)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
    at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95)
    at org.eclipse.jetty.server.Server.doStart(Server.java:282)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
    at com.google.gwt.dev.shell.jetty.JettyLauncher.start(JettyLauncher.java:740)
    at com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:522)
    at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:1104)
    at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:844)
    at com.google.gwt.dev.DevMode.main(DevMode.java:322)
   [WARN] FAILED org.eclipse.jetty.server.handler.RequestLogHandler@da24d41: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getServletRegistration(Ljava/lang/String;)Ljavax/servlet/ServletRegistration;
java.lang.NoSuchMethodError: javax.servlet.ServletContext.getServletRegistration(Ljava/lang/String;)Ljavax/servlet/ServletRegistration;
    at org.atmosphere.cpr.AtmosphereFrameworkInitializer.configureFramework(AtmosphereFrameworkInitializer.java:52)
    at org.atmosphere.cpr.AtmosphereServlet.configureFramework(AtmosphereServlet.java:84)
    at org.atmosphere.cpr.AtmosphereServlet.configureFramework(AtmosphereServlet.java:80)
    at org.atmosphere.cpr.AtmosphereServlet.init(AtmosphereServlet.java:75)
    at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:534)
    at org.eclipse.jetty.servlet.ServletHolder.doStart(ServletHolder.java:346)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
    at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:786)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:265)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1242)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:717)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:494)
    at com.google.gwt.dev.shell.jetty.JettyLauncher$WebAppContextWithReload.doStart(JettyLauncher.java:541)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
    at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95)
    at org.eclipse.jetty.server.handler.RequestLogHandler.doStart(RequestLogHandler.java:162)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
    at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95)
    at org.eclipse.jetty.server.Server.doStart(Server.java:282)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
    at com.google.gwt.dev.shell.jetty.JettyLauncher.start(JettyLauncher.java:740)
    at com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:522)
    at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:1104)
    at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:844)
    at com.google.gwt.dev.DevMode.main(DevMode.java:322)
   [WARN] FAILED org.eclipse.jetty.server.Server@1a7ded65: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getServletRegistration(Ljava/lang/String;)Ljavax/servlet/ServletRegistration;
java.lang.NoSuchMethodError: javax.servlet.ServletContext.getServletRegistration(Ljava/lang/String;)Ljavax/servlet/ServletRegistration;
    at org.atmosphere.cpr.AtmosphereFrameworkInitializer.configureFramework(AtmosphereFrameworkInitializer.java:52)
    at org.atmosphere.cpr.AtmosphereServlet.configureFramework(AtmosphereServlet.java:84)
    at org.atmosphere.cpr.AtmosphereServlet.configureFramework(AtmosphereServlet.java:80)
    at org.atmosphere.cpr.AtmosphereServlet.init(AtmosphereServlet.java:75)
    at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:534)
    at org.eclipse.jetty.servlet.ServletHolder.doStart(ServletHolder.java:346)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
    at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:786)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:265)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1242)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:717)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:494)
    at com.google.gwt.dev.shell.jetty.JettyLauncher$WebAppContextWithReload.doStart(JettyLauncher.java:541)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
    at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95)
    at org.eclipse.jetty.server.handler.RequestLogHandler.doStart(RequestLogHandler.java:162)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
    at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95)
    at org.eclipse.jetty.server.Server.doStart(Server.java:282)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
    at com.google.gwt.dev.shell.jetty.JettyLauncher.start(JettyLauncher.java:740)
    at com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:522)
    at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:1104)
    at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:844)
    at com.google.gwt.dev.DevMode.main(DevMode.java:322)

使用gwt eclipse插件部署在Jetty服务器上。

看起来你正试图 运行 在 Jetty 7 上营造气氛。

javax.servlet.ServletContext.getServletRegistration(Ljava/lang/String;)

已添加到 servlet api 的版本 3 中。 Jetty 7 实现了 2.5 版的 servlet api,因此没有实现 getServeletRegistration 方法。哪个应该解释异常。

您可以尝试将 GWT Eclipse 插件更新到 3.0 版。 (您可以在 Eclipse 市场找到它,并确保在安装新插件之前卸载旧插件。)

或者您可以尝试使用外部服务器,例如 Tomcat 7 或 8。两者都支持 Servlet 3.0 API。

希望对您有所帮助。