Resteasy 3.5.0.Final on App Engine标准环境-NoSuchFieldError SERVER_SENT_EVENTS_TYPE

Fre*_*her 5 java rest google-app-engine resteasy

我有一个使用Resteasy 3.1.4.Final的相当基本的Java8应用程序,部署在App Engine标准环境中。

但是当我将Resteasy升级到3.5.0.Final时

  • 在我当地的环境中一切都很好
  • 部署后,我得到以下Stacktrace:

来自org.jboss.resteasy.core.ResourceMethodInvoker.isSseResourceMethod(ResourceMethodInvoker.java:162)的servlet java.lang.NoSuchFieldError:SERVER_SENT_EVENTS_TYPE的未捕获异常.org.jboss.resteasy.core.ResourceMethodInvoker。(ResourceMethodInvoker。 org.jboss.resteasy.core.ResourceMethodRegistry.register(ResourceMethodRegistry.java:272)上的.jboss.resteasy.core.ResourceMethodRegistry.processMethod(ResourceMethodRegistry.java:345)在org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry .java:223),位于org.jboss.resteasy的org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:195),位于org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:181)。核心。org.org.jboss.resteasy.spi.ResteasyDeployment.registration(ResteasyDeployment.java.496)上org.jboss.resteasy.core.ResourceMethodRegistry.addPerRequestResource(ResourceMethodRegistry.java:77)上的ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:158) org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:86)上的.jboss.resteasy.spi.ResteasyDeployment.startInternal(ResteasyDeployment.java:279)在org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.init(HttpServletDispatcher.java:36)上的.init(ServletContainerDispatcher.java:119)org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:643) ),网址为org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:422)在org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:892)在org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:349)在org.eclipse.jetty.webapp.WebAppContext org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1368)的.startWebapp(WebAppContext.java:1406)org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:778) org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:522)上的org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:262)在org.eclipse.jetty.util.component.AbstractLifeCycle上。在com.google.com上从com.google.apphosting.runtime.jetty9.AppVersionHandlerMap.createHandler(AppVersionHandlerMap.java:244)开始(AbstractLifeCycle.java:68)。com.google.apphosting.runtime.jetty9.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:97)上的apphosting.runtime.jetty9.AppVersionHandlerMap.getHandler(AppVersionHandlerMap.java:182)在com.google.apphosting.runtime.JavaRuntime $ RequestRunnable上。 com.google.apphosting.runtime.JavaRuntime $ RequestRunnable.dispatchRequest(JavaRuntime.java:642)上的com.google.apphosting.runtime.JavaRuntime $ RequestRunnable.run(JavaRuntime.java:612)上的dispatchServletRequest(JavaRuntime.java:680)在com.google.apphosting.runtime.ThreadGroupPool $ PoolEntry.run(ThreadGroupPool.java:274)在com.google.apphosting.runtime.ThreadGroupPool $ PoolEntry.run(ThreadGroupPool.java:274)在com.google.apphosting.runtime.JavaRuntime $ NullSandboxRequestRunnable.run(JavaRuntime.java (线程.java:745)182),com.google.apphosting.runtime.jetty9.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:97),com.google.apphosting.runtime.JavaRuntime $ RequestRunnable.dispatchServletRequest(JavaRuntime.java:680),com.google.apphosting com.google.apphosting.runtime.JavaRuntime $ RequestRunnable.run(JavaRuntime.java:612)上的.runtime.JavaRuntime $ RequestRunnable.dispatchRequest(JavaRuntime.java:642),com.google.apphosting.runtime.JavaRuntime $ NullSandboxRequestRunnable.run (javaRuntime.java:806)在com.google.apphosting.runtime.ThreadGroupPool $ PoolEntry.run(ThreadGroupPool.java:274)在java.lang.Thread.run(Thread.java:745)182),com.google.apphosting.runtime.jetty9.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:97),com.google.apphosting.runtime.JavaRuntime $ RequestRunnable.dispatchServletRequest(JavaRuntime.java:680),com.google.apphosting com.google.apphosting.runtime.JavaRuntime $ RequestRunnable.run(JavaRuntime.java:612)上的.runtime.JavaRuntime $ RequestRunnable.dispatchRequest(JavaRuntime.java:642),com.google.apphosting.runtime.JavaRuntime $ NullSandboxRequestRunnable.run (javaRuntime.java:806)在com.google.apphosting.runtime.ThreadGroupPool $ PoolEntry.run(ThreadGroupPool.java:274)在java.lang.Thread.run(Thread.java:745)com.google.apphosting.runtime.JavaRuntime $ RequestRunnable.dispatchRequest(JavaRuntime.java:642)上的JavaRuntime $ RequestRunnable.dispatchServletRequest(JavaRuntime.java:680)com.google.apphosting.runtime.JavaRuntime $ RequestRunnable.run(JavaRuntime。 java:612),位于com.google.apphosting.runtime.JavaRuntime $ NullSandboxRequestRunnable.run(JavaRuntime.java:806),位于com.google.apphosting.runtime.ThreadGroupPool $ PoolEntry.run(ThreadGroupPool.java:274), .Thread.run(Thread.java:745)com.google.apphosting.runtime.JavaRuntime $ RequestRunnable.dispatchRequest(JavaRuntime.java:642)上的JavaRuntime $ RequestRunnable.dispatchServletRequest(JavaRuntime.java:680)com.google.apphosting.runtime.JavaRuntime $ RequestRunnable.run(JavaRuntime。 java:612),位于com.google.apphosting.runtime.JavaRuntime $ NullSandboxRequestRunnable.run(JavaRuntime.java:806),位于com.google.apphosting.runtime.ThreadGroupPool $ PoolEntry.run(ThreadGroupPool.java:274), .Thread.run(Thread.java:745)806),位于com.google.apphosting.runtime.ThreadGroupPool $ PoolEntry.run(ThreadGroupPool.java:274),位于java.lang.Thread.run(Thread.java:745)806),位于com.google.apphosting.runtime.ThreadGroupPool $ PoolEntry.run(ThreadGroupPool.java:274),位于java.lang.Thread.run(Thread.java:745)

因此,这似乎与环境有关。有解决的线索吗?

谢谢

Fre*_*her 6

我正在发布我在Github 中收到的@NicoNes 的回答

嗨@freddyboucher 我不认为这次提交是你正在处理的 NoSuchFieldError 的原因。Resteasy 3.1.4.Final 是 JAX-RS-API 2.0.1 规范的实现,而 3.5.1.Final 是 JAX-RS-API 2.1 规范的实现。您正在谈论的缺失字段来自 JAX-RS-API 2.1 中的 javax.ws.rs.core.MediaType。那么您能否确保您的运行时执行没有嵌入错误的 JAX-RS-API 版本?

让我知道。

-尼古拉斯

他是对的,我在 pom.xml 中有:

  <dependencyManagement>
      <dependencies>
        <dependency>
          <groupId>javax.ws.rs</groupId>
          <artifactId>javax.ws.rs-api</artifactId>
          <version>2.0.1</version>
        </dependency>
      </dependencies>
  </dependencyManagement>
Run Code Online (Sandbox Code Playgroud)

升级到 2.1,解决了我的问题!